cat
: concatenate files and print on the standard outputcat > a.txt
: start a file creationcat a.txt
: show file contentcat a.txt b.txt
: show files content respectivelycat a.txt b.txt > c.txt
: create a file which contains a.txt and b.txt
chmod
: change file mode bitschmod +x a.txt
: All users and groups have the execute permissionchmod $u$g$o a.txt
: Give specific user permission- $u -> current user permission number
- $g -> current user's group permission number
- $u -> others permission number
- permission number can calculate with:
- 0 -> no permission
- 1 -> x (execute)
- 2 -> w (write)
- 4 -> r (read)
chmod 651 a.txt
: it means user can write and read, group can read and execute, others can only execute.
cd
: change directorycd a/
: change directory to a (which is a directory in my current directory)cd /opt/
: change directory to opt (full path start with /)cd ../
:one directory upcd ./
: this directorycd
: return home directory for your user
cp
: copy files and directoriescp $source $destination
: copy the file from source to destionationcp -R a/ b/
: copy directory(folder) to other folder. (-R = -r = --recursive)
date
: print or set the system date and timeecho
: display a line of text, args etc.echo "string"
: it prints out "string"echo $PATH
: it prints $PATH variable's value
grep
: print lines matching a patterncat b.txt | grep q
: the lines which containsq
in b.txt.cat b.txt | grep q$
: the lines which ends withq
in b.txt.cat b.txt | grep ^q
: the lines which starts withq
in b.txt.- ! for regex usage you can only specify the -E(or -e):
cat b.txt | grep -E q$
.
head
: output the first part of fileshead b.txt
: first 10 lines of the b.txt (default)head b.txt -n 4
: first 4 lines of the b.txt
ls
: list directory contentsls
: list current directory contents (only general files ignore hidden files(which starts with.
))ls a/
: list directorya
's contentsls -l
: list current directory contents (long list format)ls -a
: list current directory all contents (do not ignore hidden files)ls -la
: all file in long list format
more
: file perusal filter for crt viewingmore b.txt
: paginate the contents of the b.txtcat b.txt | more
: this also paginates
less
: opposite of moremkdir
: make directories- mkdir NEWFOLDERNAME: create a folder(directory) name NEWFOLDERNAME
mv
: move (rename) filesmv $source $destination
: move folder and files from source to destination (you can use it to rename a folder or file)
pwd
: print name of current/working directoryrm
: remove files or directoriesrm b.txt
: delete file namedb.txt
rm -r a/
: delete folder nameda
rmdir
: remove empty directoriesrmdir a/
: delete directory if and only if the directory is empty
export
: set an environment variableexport VARIABLE_NAME="VALUE OF VARIABLE"
: it creates a variable named VARIABLE_NAME. (access name $VARIABLE_NAME)
sort
: sort lines of text filesqtail
: output the last part of filestail b.txt
: last 10 lines of the b.txt (default)tail -n 4 b.txt
: last 4 lines of the b.txt
tar
: The GNU version of the tar archiving utility (tape archive)tar -tvzf foo.tar.gz
: list all files name in foo.tar.gztar -zcvf archive-name.tar.gz directory-name
: create a tar.gz file from directory-nametar -xvzf foo.tar.gz
: uncompress all files in foo.tar.gz- -z: using gzip program
- -x: extract (uncompress)
- -c: create archive
- -v: verbose (display progress while creating archive)
- -f: archive file name
ssh
: OpenSSH SSH client (remote login program)ssh eng1.mu.edu.tr
: connect the eng1.mu.edu.tr server with SSH (it get your current username as a username in the server).ssh mo.tercanli12@eng1.mu.edu.tr
: connect the server with username: mo.tercanli12
wc
: print newline, word, and byte counts for each filewc b.txt
: prints out the number of Lines, Words, Characterswc -l b.txt
: only number of lineswc -w b.txt
: only number of wordswc -c b.txt
: only number of character
scp
: secure copy (remote file copy program)scp your_username@remotehost.edu:foobar.txt /some/local/directory
: copy file from remote to localscp foobar.txt your_username@remotehost.edu:/some/remote/directory
: copy file from local to remote
wget
: The non-interactive network downloader.wget $URL
: download url content from $URLwget $URL -O a.txt
: download url content from $URL and save it asa.txt
curl
: transfer a URLfind
: search for files in a directory hierarchyman
: an interface to the on-line reference manualsman tar
: manual page for tar
sed
: stream editor for filtering and transforming textsed s/one/ONE/
< a.txt: it process the filea.txt
and allone
becomeONE
. (a.txt does not change)
awk
: pattern scanning and processing language
//copy files from text list to folder function cp_files_from_text_list_to_folder() { TEXTLIST=$1 DESTINATION=$1 cat $TEXTLIST | xargs -J % cp % $DESTINATION }