Show Menu

Linux CLI Cheat Sheet (DRAFT) by [deleted]

Cheat Sheet for Linux CLI

This is a draft cheat sheet. It is a work in progress and is not finished yet.


All commands are single line commands despite any line breaking.

Any commands containing "­$" are commands that accept one or more inputs. Examples of common inputs are as follows:

$file - A file such as "­/va­r/w­ww/­htm­l/i­nde­x.h­tml­"
$dir - A directory such as "­/va­r/w­ww/­htm­l/"
$pid - A process ID
$command - Another Linux command
$pattern - A RegEx pattern, or string such as "­htm­l" (string) or "­[\d­]{1­,2}­" (regex)
$domai­n.tld - A domain such as "­goo­­m"

System Inform­ation

Show the calendar for the month
Show current date and time
Show current uptime
Show who is logged into the system
Show who you are logged in as
finger $user
Show inform­ation about $user
uname -a
Show kernel inform­ation
cat /proc/­cpuinfo
Show CPU inform­ation
cat /proc/­meminfo
Show memory inform­ation
man $command
Show the manual page for $command
df -h
Show disk usage
du -h
Show current directory space usage
free -m
Show memory usage in MB
which $command
Shows location of executable for $command


grep $pattern $file
Search inside $file for $pattern
grep -r $pattern $dir
Search all files inside of $dir for $pattern
$command | grep $pattern
Search output of $command for $pattern
locate $file
Find all instances of $file

Process Management

ps aux
Show all running processes
Monitor all running processes
kill $pid
Kill process with pid $pid
kill -9 $pid
Force kill process with pid $pid
killall $proc
Kill all processes named $proc
Lists stopped or background processes
Bring the most recent process to the foreground
fg $a
Brings process $a to the foreground
ps aux and top both give you the pid of a process

Keyboard Shortcuts

Halt the current process
Stop the current process (Resume with fg or resume in background with bg)
Logout of session
Erase from cursor to end of word
Erase entire line
Move cursor to start of line
Move cursor to end of line

File and Directory Management

Print path of current directory
List files and direct­ories in current directory
cd $dir
Change to directory at $dir
mkdir $dir
Make a directory called $dir
rm $file
Delete $file
rm -r $dir
Delete directory $dir
mv $a $b
Move file or directory at $a to $b. If $b is a directory, the file will be put inside of the directory. If $b is a file name, it will be overwr­itten with $a
With "rm $" and "rm -r" adding "­-f" will force the file or directory to be deleted regardless of the state of object.


ping $host
Ping $host and output results
whois $domai­n.tld
Get registry inform­ation for $domai­n.tld
nslookup $domai­n.tld
Get abbrv. DNS inform­ation for $domai­n.tld
dig $domai­n.tld
Get full DNS inform­ation for $domai­n.tld
dig -x $domai­n.tld
Get reverse DNS inform­ation for $domai­n.tld
wget $url
Download file at $url

File Permis­sions

There are two ways to change file permis­sions:

chmod $octal $file
chmod $perms $file

Where $octal is a triad of octal digits (000 to 777)

Where 4 = read permis­sions, 2 = write permis­sions, 1 = execute permis­sions. You can define permis­sions by adding together the octals digits such that 5 = read/e­xecute permis­sions, 6 = read/w­rite, 3 = write/­exe­cute, and so on.

Each position represents permis­sions for "­own­er" "­gro­up" and "­wor­ld".