UNIX shell cheat sheet
The shell allows maintenance tasks, such creating, copying, moving, renaming,... of files and
directories/ Among many other things, it also allows to search for files and contents of files.
Focus
change directory to the users home directory
cd
Directory
change directory to the users home directory
cd $HOME
change directory to the directory that is outside
cd ..
of the current one
mkdir directory1
Create directory directory1
Manipulating
Rename file1 to file2, works also with directories
mv file1 file2
Copy file1 to file2
cp file1 file2
Copy file1 to file2 using pipelining
cat file1 > file2
Show file1
cat file1
less file1
Show file1 with paging, leave this mode using q,
Top is g, Bottom is G, paging is <spacebar>
Open text file editor (if all key-presses fail try
nano file1
Cntrl-G, or Cntrl-C)
finding
find a file name starting in the current directory
find . -name file1
and all subdirectories
find a file name starting in the directory dir1
find dir1 -name file1
find a file name containing the letters fi starting
find . -name ’*fi*’
in the current directory
find a file name beginning with the letters fi
find . -name ’fi*’
starting in the current directory
find all lines in file1 that contain the text ”is
grep "is this" file1
this”
find all lines in file1 that begin with ”is this”
grep "^ ı s this" file1
grep "[tT]his" file1
find all lines in file1 that contain the text ”this”
or ”This”
Changing text
tr -s ’\r\n’ ’\n’ < file1 > file2: Change all windows end-of-line
characters to UNIX end-of-line characters but
piping file1 to file2