# Linux command cheat sheet In this cheat-sheet file usually means file or directory ~ is a linux short-hand for your home-directory | **Command** | **Description/explanation** | **Useful options** | **Examples** | | ----------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------- | | ssh | secure shell  \- remote login to another linux machine | | ssh ola@saga.sigma2.no | | hostname | Given name to machine | | | cd | change directory – move around in your file hierarchy | | cd ~/documents | | pwd | print working directory | | | | ls | List – list content of directory | \-l,-lh | ls documents | | echo | print out something | | echo "Hi there" | | mkdir | Make directory | \-p | | | cp | copy | | cp file1.txt ~/documents/file2.txt | | mv | move | | mv file1.txt ~/documents/file2.txt | | rm | remove | \-f, -r, -i | rm -i file1.txt | | cat | Cocatenate – used to view contents of a text file
or fill text-file with contents | | cat file1.txt | | more | View text file in command promt, move
forward one page at a time | | more file1.txt | | less | Similar to more – but you can move
forwards and backwards | | less file1.txt | | head | Print out top N lines of text file | \-n | head file1.txt | | tail | Print out bottom N lines of text file | \-n | tail file1.txt | | diff | Print out differences between files | | diff file1.txt ~/documents/file2.txt | | wget | Download files from the internet | | wget https://www.nrk.no | | tar | Archive or unarchive files | xvf (x: extract v: verbose f: filename)
cvf (c: create) | tar xvf demo-moving-around.tar.gz | | find | Find files in the file hierarchy | | find file1.txt ~/ | | touch | Create, modify and change timestamps of a file | | touch newfile.txt
touch existingfile.txt | | grep | Searches through files and prints out
occurrences of the string grepped | | grep car texaboutcars.txt | | bash | Sh-compatible command language interpreter | | | | chmod | change mode – change permission mode
of file – read/write/execute | \-R | chmod u+x file1.exe
chmod 0700 file1.exe | | sort | Sort the given input | | | | uniq | Filters out repeated occurences | | | | wc | Word count | \-l,\-c,\-m | wc textaboutcars.txt | | history | Show bash history | | | | xargs | Build and execute command lines
from standard input | | | | man | Linux manual – all linux commands have
a man page showing required
and optional parameters to the linux command | | man ls |