File Commands

lsdirectory listing
ls -alformatted listing with hidden files
cd dirchange directory to dir
cd change to home
pwdshow current directory
mkdir dircreate a directory dir
rm filedelete file
rm -r dirdelete directory dir
rm -f fileforce remove file
rm -rf dirforce remove directory dir*
cp file1 file2copy file1 to file2
cp -r dir1 dir2copy dir1 to dir2, create dir2 if doesn’t exist
mv file1 file2rename or move file1 to file2, if file2 is an existing directory,
move file1 into directory file2
ln -s file linkcreate symbolic link link to file
touch filecreate or update file
cat > filePlaces standard input into file
more fileoutput the contents of file
head fileoutput the first 10 lines of file
tail fileoutput the last 10 lines of file
tail -f fileoutput the contents of file as it grows, starting with the last 10 lines


grep pattern filessearch for pattern in files
grep -r pattern dirsearch recursively for pattern in dir
command | grep patternsearch for pattern in the output command
locate filefind all instances of file

Process Management

psdisplay your currently active processes
kill pidkill process id pid
killall prockill all processes named proc (use with extreme caution)
bglists stopped or background jobs; resume a stopped job in the background
fgbring the most recent jo to foreground
fg nbrings job n to the foreground


Ctrl+Chalts the current command
Ctrl+Zstops the current command, resume with fg in the foreground or bg in the background
Ctrl+Dlog out of current session, similar to exit
Ctrl+Werase one word in the current line
Ctrl+Uerase the whole line
Ctrl+Rtype to bring up a recent command
!!repeats the last command
exitlog out of current session

System Info

dateshow the current date and time
calshow this month’s calendar
uptimeshow current uptime
wdisplay who is online
whoamiwho you are logged in as
finger userdisplay information about user
uname -a show kernel information
cat /proc/cpuinfocpu information
cat /proc/meminfomemory information
man commandshow the manual for command
dfshow disk usage
dushow directory space usage
freeshow memory and swap usage
whereis appshow possible location of app
which appshow which app will be run by default


tar cf file.tar filescreate a tar named file.tar containing files
tar xf file.tarextract the files from file.tar
tar czf file.tar.gz filescreate a tar with Gzip compression
tar cjf file.tar.bz2create a tar with Bzip2 compression
tar xjf file.tar.bz2extract a tar using Bzip2
gzip filecompresses file and renames it to file.gz
gzip -d file.gzdecompresses file.gz back to file
tar xzf file.tar.gzextracting a tar using Gzip


ping hostping host and output results
whois domainget whois information for domain
dig domainget DNS information for domain
dig -x hostreverse lookup host
wget filedownload file
wget -c filecontinue a stopped download


make install
Install from source
dpkg -i pkg.debinstall a package (Debian)
rpm -Uvh pkg.rpminstall a package (RPM)

File Permissions

chmod octal filechange the permission of file to octal, which can be found separately for user, group, and world by adding:
4 – read (r)
2 – write (w)
1 – execute (x)
chmod 777 – read, write, execute for all
chmod 755rwx for owner, rx for group and world
for more options, see man chmod