Linux Command Library

Clear and reset the terminal

To clear the terminal use the command below or press Ctrl+L on your keyboard.
 $ clear 

If you screw up the screen by e.g. accidentally reading a binary file with with cat or less you might reinitialisation the terminal with the reset command.
 $ reset 

List of recent commands

Use the history command or open the history file in vim $HISTFILE or any other text editor.
 $ history 

Tab Completion

This might save you a lot of time. If you e.g. want to delete a file with a very long name you can type the first few characters of the name and press TAB to auto complete the name. If there are more then one possibilities and you press TAB twice you get a list of all possibilities.

Special characters in commands

Shell special characters are interpreted by the shell as soon as it is given the command. For example, if you type ls *.bak, the shell translates *.bak to the list of all files in the current directory whose names end in .bak. The ls command never sees the asterisk. So if you want to search for files which actually have an asterisk in their names, you have to escape the asterisk to stop the shell from interpreting it.
/escapes itself and other specials
*stands for anything (including nothing)
 $ find ex*.txt 
?stands for any single character
 $ find ex?mple.txt 
[ ]encloses patterns for matching a single character
 $ find ex[abc]mple.txt 
( )runs the contents of the parentheses in a sub-shell
 $ pwd && (cd /etc) && pwd 
;terminates a command pipeline - use it to separate commands on a single line
 $ echo Hi ; uname 
' 'The contents of the single quotes are passed to the command without any interpretation.
 $ find '(echo abc)'* 
(echo abc).txt
` `The contents of the backquotes are run as a command and its output is used as part of this command
 $ echo `uname
" "The contents of the quotes are treated as one argument; any specials inside the quotes, except for $ and ``, are left uninterpreted.
 $ cd "untitled folder" 
|Pipes allow you to send the output of a command to another command.
 $ fortune | cowsay 
&Run a command in the background.
 $ cowsay
&&Only execute the second command if the first one was successful.
 $ ping locahost -c 1 && cowsay great 
||Only execute the second command if the first one was unsuccessful.
 $ ping "not.reachable" -c 1 && cowsay sorry 
< >These symbols are used for redirection; see below.
!If ! is immediately followed by a character other than =, it begins a history substitution; if it is followed by a space it negates the return code of the following command pipeline.
 $ sudo !! 
^Quick history substitution, changing one string to another.
 $ ls *.png 
 $ ^png^xcf^ 
ls *.xcf
#Turns the line into a comment; the line is not processed in any way.
 $ whatis xdotool # hint: has sth. todo with X11 
Don't confuse shell special characters with special characters in regular expressions. Regular expressions must be protected from the shell by enclosing them in single quotes.


You can redirect standard input, output and error by adding these sequences after a command
>send output to file (overwriting and destroying whatever is in the file already)
 $ echo "Write output to file" > example.txt 
>>append output to file
 $ echo "Append this to file" >> example.txt 
<take input from file
 $ cowsay < example.txt 
2>send error messages to file (overwriting). (This means that errors can be directed separately from normal output.)
play store download app store download
Sonnenallee 29, 12047 Berlin, Germany

Privacy policy
Successfully copied