Show Menu

Basic Linux Commands Cheat Sheet by

Basic Linux commands you should know

File Commands

ls – directory listing
ls -al – formatted listing with hidden files
cd [direc­tory] - change directory to directory
pwd – Print Working Directory
mkdir [direc­tory] – create a directory named directory
rm [file_­name] – delete filename
rm -r [direc­tory] – delete directory recurs­ively
rm -f [file_­name] – force remove file
rm -rf [direc­tory] – force remove directory directory recurs­ively * Use with care
cp [file1 file2] – copy file1 to file2
mv [file1 file2] – rename or move file1 to file2
ln -s [file_name link] – create symbolic link to file
touch [file_­name] – create or update file
cat > [file_­name] – places standard input into file
more [file_­name] – output the contents of file
head [file_­name] – output the first 10 lines of file
tail [file_­name] – output the last 10 lines of file
tail -f [file_­name] – output the contents of file as it grows, starting with the last 10 lines
chmod [octal file_name] change the permis­sions of file to octal


tar cf [file_­nam­e.tar files] – create a tar named file_n­ame.tar containing files
tar xf [file_­nam­e.tar] – extract the files from file_n­ame.tar
tar czf [file_­nam­e.t­ar.gz files] – create a tar file with Gzip compre­ssion
tar xzf [file_­nam­e.t­ar.gz] – extract a tar using Gzip
tar xjf [file_­nam­e.t­ar.bz2] – extract a tar using Bzip2
gzip [file_­name] – compresses file and renames it to file_n­ame.gz
gzip -d [file_­nam­e.gz] – decomp­resses file_n­ame.gz back to file

System Inform­ation

date – show the current date and time
cal – show this month's calendar
uptime – show current uptime
w – display who is online
whoami – who you are logged in as
finger user – display inform­ation about user
uname -a – show kernel inform­ation
cat /proc/­cpuinfo – cpu inform­ation
cat /proc/­meminfo – memory inform­ation
man command – show the manual for command
df – show disk usage
du – show directory space usage
free – show memory and swap usage
whereis [appli­cat­ion­_name] – show possible locations of binary, source, and manual page files for a command
which [appli­cat­ion­_name] – show which applic­ation will be run by default


grep [pattern files] – search for pattern in files
grep -r [pattern directory] – search recurs­ively for pattern in directory
[command] | grep [pattern] – search for pattern in the output of command
locate [file_­name] – find all instances of file

Process Management

ps – (Process Status) displays your currently active processes
top – (Table of Processes) display all running processes
kill [pid] – kill process id pid
killall [proce­ss_­name] – kill all processes named [proce­ss_­name]
bg – lists stopped or background jobs; resume background job
fg – brings the most recent job to foreground
fg [n] – brings job id to the foreground


ping [host] – ping host and output results
whois [domain] – get whois inform­ation for domain
dig [domain] – get DNS inform­ation for domain
dig -x [host] – reverse lookup host
wget [file at URL] – download file from URL
wget -c [file at URL] – continue a stopped download
ssh [user@­host] – connect to host as user
ssh -p [port user@host] – connect to host on port port as user
ssh-co­py-id [user@­host] – add your key to host for user to enable a keyed or login without password


Ctrl+C – halts the current command
Ctrl+Z – stops the current command; resume with fg in the foreground or bg in the background
Ctrl+D – log out of current session, similar to exit
Ctrl+W – erases one word in the current line
Ctrl+U – erases the whole line
Ctrl+R – type to bring up a recent command
!! - repeats the last command
exit – log out of current session


Hey, this is good for SysAdmins.

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Regular Expressions Cheat Sheet
          Python Cheat Sheet
          OneStop(Nerd)Shop Cheat Sheet

          More Cheat Sheets by NexWebSites

          Modern C++ 17 Standard Library Features Cheat Sheet