The Linux Command Line Cheat Sheet
The Linux Command Line Cheat Sheet
Terminal
history Display recently used commands. You can also view these commands via the Up
and Down keys.
! Repeat a recently used command. You can use !n to repeat the n-th command in
history or !-n to repeat what happened n commands ago.
whatis Display a brief description of a terminal program. A simpler alternative to the man
command.
alias Create a shortcut to a command or, when combined with the cd command,
directory.
cp Makes a copy of a file. Defaults to the current directory unless you specify a
specific one.
touch Change the date accessed or date modified time of a given file to right now.
mkdir Create a directory. Defaults to the current directory, but you can also specify one.
rmdir Delete a directory. Defaults to the current directory, but you can also specify one.
The target directory must be completely empty.
find Search a specific directory (or your entire PC) to find files that match designated
criteria.
locate Search for files or directories. Faster than the find command, but has fewer options.
grep Search a specific file or set of files to see if a string of text exists and where.
mount Attach a separate filesystem (such as an external hard drive or USB stick) to your
system's main filesystem.
cat Display the contents of a text file. Also works with multiple files.
Users
su Switch user. Unless you desigate a specific user, this command will attempt to sign
in as the root user (which you can think of as the system administrator).
System Administration
uname Displays core system information such as kernel version, hardware, and operating
system.
sudo Enter before a command to perform the command as a system administrator. User
must have administrator priveleges for this to work.
apt/dnf/ Programs for installing software and updates. Which one to use depends on your
pacman Linux-based operating system. Each requires administrator rights and additional
instructions, such as sudo apt install program-name .
jobs Display the status of all current jobs. A job is a representation of a running process
or group of processes.
kill End a process according to its process ID (which you can get using the ps
command.
top Displays a list of running processes, sorted by how much CPU each uses. Unlike
ps, the command updates in real-time.
uptime Displays time since last boot.
df Displays how much disk space is used and free on your system.
free Displays how much RAM is used and free on your system.
Network Management
ping Send or receive data from another computer on a network. Often used to test
whether a network connection is established and the speed of that connection.
Miscellaneous
echo Display a line of text. Often used in programs and scripts to relay information to
users.