The Linux command line, also known as the terminal, can be an intimidating place. But it can also be your most effective tool.
Text commands often work regardless of which Linux-based operating system you use, and the results are often faster than what a graphical desktop interface can offer.
Yet even for long-time users, there are too many commands to commit to memory. That’s why we’ve prepared this handy cheat sheet of Linux commands.
The Linux Command Line Cheat Sheet
Terminal | |
clear | Clear the terminal screen. |
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. |
man | Display the manual for a terminal program. |
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. |
exit | Exit or close the terminal. |
Navigation & File Management | |
cd | Change directory. Used to navigate between folders. |
pwd | Display current directory. |
cd | Change current directory. |
ls | Display a list of files in the current directory. |
cp | Makes a copy of a file. Defaults to the current directory unless you specify a specific one. |
mv | Move a file from one directory to another. |
rm | Remove a file or set of files. |
stat | Display when a file was last accessed, modified, or changed. |
touch | Change the date accessed or date modified time of a given file to right now. |
rmdir | Delete a file or files. |
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. |
rename | Change the name of a file or set of files. |
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. |
umount | Detach a separate filesystem from your system’s main filesystem. |
cat | Display the contents of a text file. Also works with multiple files. |
chmod | Modify the read, write, and execute permissions of a file. |
chown | Change the user or group that owns a file. |
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). |
whoami | Displays the current user name. |
id | Display current user and group. |
passwd | Create or update a user’s password. |
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/pacman | Programs for installing software and updates. Which one to use depends on your 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. |
bg | Send a job to the background. |
fg | Send a job to the foreground. |
kill | End a process according to its process ID (which you can get using the ps command. |
killall | End all processes whose names match your query. |
ps | Display a list of running processes. Defaults to processes started by the current user. |
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. |
whereis | Finds the executable file for a program. |
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 | |
ip | Displays you IP address, network interfaces, bandwidth usage, and more. |
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. |
dig | Look up a domain’s DNS address |
wget | Download a file. |
ssh | Secure Shell. Connect and login to a remote network location. |
Miscellaneous | |
echo | Display a line of text. Often used in programs and scripts to relay information to users. |
factor | Displays possible factors of a decimal number. |
expr | Solve math equations. |
look | Look up a word in the dictionary. |
More Linux Terminal Commands
As comprehensive as this Linux commands cheat sheet may be, the list is only scratching the surface. There is far more you can do in the terminal than we could ever hope to fit on one page. Plus many commands change depending on your Linux-based operating system or require installing additional programs. The commands above are likely to work out-of-the-box on most Linux machines.
All the items in this cheat sheet are useful, but there are other Linux commands that are just plain fun. Then, on the flip side, there are commands that no one should ever run.
Read the full article: The Linux Commands Reference Cheat Sheet