Linux is one of the popular operating systems, and since it is open source, it has a lot of versions built on it. However, one thing remains unchanged, using commands to do everything on Linux. For instance, using “mkdir” to create a directory or using cd to change the active working directory. There are so many helpful commands that, after some time, we just get used to them. And to make it easier for you to know and use most of the Linux commands, here I am with a Linux Commands Cheat Sheet.
Linux does have its own cheat sheet for all the commands, and you can access it by using the man page. It is a manual for each command, how to use it, descriptions, and examples. However, at times, they are weirdly scary, with a huge index and a little difficult to understand.
Also Read: 11 Best Linux Distro For Programmers
Linux Commands Cheat Sheet: Use Linux Like a Pro
In this Linux Commands Cheat Sheet, we group Linux commands based on their operations, such as file operations, networks, and more. This should make the Linux Commands Cheat Sheet easier for you to understand, and you can directly refer to commands based on your interests.
To start with, let’s look at some commands that come in handy to do basic tasks. For instance, changing directories, listing files, and more. Don’t worry if they repeat later.
Quick Tip: Bookmark this Linux Commands Cheat Sheet to get a quick eye when in need.
Basic Linux Commands
Linux Command | Description |
---|---|
man | Displays the manual pages for a command |
ls | Lists files and directories from the current working directory |
cd | Changes the current working directory to new directory |
pwd | Prints the current working directory |
mkdir | Creates a new directory |
touch | Moves or renames files and directories |
cp | Copies, files, and directories |
mv | Moves or renames file and directories |
rm | Removes files and directories |
cat | Displays the contents of a file |
less | Displays the contents of a file one page at a time |
head | Shows the first few lines of a file |
tail | Displays the last few lines of a file |
grep | Searches for a pattern in files |
find | Searches for files and directories |
tar | Creates or extracts compressed archives |
chmod | Changes the permissions of a file or directory |
chown | Changes the owner of a file or directory |
chgrp | Changes the group of a file or directory |
ssh | Connects to a remote server using the secure shell protocol |
scp | Copies files between a local and remote server securely |
wget | Downloads files from the internet |
history | Shows the command history |
ps | Displays the running processes |
kill | Terminates a process |
su | Switches to another user account |
sudo | Executes a command with superuser privileges |
df | Shows the disk space usage of file systems |
du | Displays the disk usage of files and directories |
ifconfig | Displays network interface configuration |
ping | Sends ICMP echo requests to a network host |
netstat | Shows network connections and statistics |
ssh-keygen | Generates SSH key pairs for secure authentication |
source | Executes commands from a file in the current shell |
Also Read: Want to Change Your Linux User Password? Here is the Guide For You
Linux Network Commands
Linux Network Commands | Description |
---|---|
ifconfig | Displays or configures network interfaces |
ip | Shows or manipulates routing, devices, policy routing, and tunnels |
ping | Sends ICMP echo requests to a network host to check connectivity |
traceroute | Prints the route packets take to a destination host, showing each hop along the way |
netstat | Shows network connections, routing tables, and network interface statistics |
nslookup | Performs DNS lookups to retrieve domain name or IP address information |
dig | Performs DNS queries and displays detailed information about DNS records |
host | Performs DNS lookups and displays information about a particular host or domain |
ssh | Connects to a remote server using the secure shell protocol |
scp | Copies files between a local and remote server securely |
ftp | Transfers files to and from a remote file server using the FTP protocol |
curl | Sends HTTP requests and displays the response from a server |
telnet | Connects to a remote host using the Telnet protocol |
ifup | Brings a network interface up |
ifdown | Brings a network interface down |
route | Shows or manipulates the IP routing table |
iptables | Manages firewall rules and network address translation (NAT) |
tcpdump | Captures and analyzes network traffic |
nmap | Scans network hosts and services to discover open ports and gather information |
arp | Displays or modifies the Address Resolution Protocol (ARP) cache |
ss | Shows detailed information about network sockets and connections |
route add | Adds a static route to the routing table |
route del | Deletes a static route from the routing table |
ethtool | Displays or modifies Ethernet device settings and statistics |
iwconfig | Configures wireless network interfaces |
hostname | Displays or sets the system’s hostname |
tcpdump -i | Captures network traffic on a specific network interface |
iftop | Displays real-time network bandwidth usage by individual connections |
netcat | Establishes network connections, reads from and writes to network sockets |
Also Read: Best & Free Network Monitoring Tools for Linux
Linux File Commands
File Command | Description |
---|---|
ls | Lists files and directories in the current directory |
cd | Changes the current directory |
pwd | Prints the current working directory |
mkdir | Creates a new directory |
touch | Creates an empty file or updates the timestamp of an existing file |
cp | Copies files and directories |
mv | Moves or renames files and directories |
rm | Removes files and directories |
cat | Concatenates and displays the contents of files |
less | Displays the contents of a file one page at a time |
head | Displays the first few lines of a file |
tail | Displays the last few lines of a file |
file | Determines the file type |
find | Searches for files and directories based on various criteria |
locate | Finds files and directories using a pre-built database |
grep | Searches for a pattern in files |
wc | Counts the number of lines, words, and characters in a file |
diff | Compares and displays the differences between two files |
cmp | Compares two files byte by byte |
ln | Creates a hard or symbolic link to a file or directory |
chmod | Changes the permissions of a file or directory |
chown | Changes the owner of a file or directory |
chgrp | Changes the group ownership of a file or directory |
gzip | Compresses files using the gzip compression algorithm |
gunzip | Decompresses files compressed with gzip |
tar | Creates or extracts compressed archives |
zip | Compresses files into a zip archive |
unzip | Extracts files from a zip archive |
stat | Displays file or file system status |
du | Shows the disk usage of files and directories |
df | Shows the disk space usage of file systems |
mount | Mounts a file system to a specified mount point |
umount | Unmounts a mounted file system |
sync | Flushes file system buffers |
Also Read: How to Delete Files and Directories in Linux – Simple Guide
Linux User and Group Commands
User and Group Commands | Description |
---|---|
useradd | Adds a new user to the system |
userdel | Deletes a user account from the system |
usermod | Modifies user account properties such as username, home directory, or default shell |
passwd | Sets or changes the password for a user account |
su | Switches to another user account or becomes the superuser |
sudo | Executes a command with superuser privileges |
chown | Changes the owner of a file or directory |
chgrp | Changes the group ownership of a file or directory |
chmod | Changes the permissions of a file or directory |
groups | Displays the groups a user belongs to |
id | Displays the user and group information for a given username or current user |
whoami | Prints the username of the current user |
adduser | Interactive command for creating new user accounts |
deluser | An interactive command for deleting user accounts |
groupadd | Creates a new user group |
groupdel | Deletes a user group |
groupmod | Modifies group properties such as group name or GID |
gpasswd | Manages the group password file, including adding or deleting members and managing group administrators |
newgrp | Switches to a different group |
passwd | Changes the password for a user or group |
finger | Displays information about user accounts, such as login name, full name, and terminal |
who | Shows the list of currently logged-in users |
w | Displays information about currently logged-in users and their activities |
last | Shows the list of last logged-in users and their login history |
logname | Prints the login name of the current user |
usermod -G | Adds or removes a user from a specific group |
usermod -s | Changes the default shell for a user |
usermod -l | Renames a user account |
groupmod -n | Renames a group |
pwck | Checks the integrity of password and shadow files |
su -c | Executes a command as another user |
Also Read: How to Rename Files and Directories in Linux?
Linux Process Commands
Process Commands | Description |
---|---|
ps | Displays information about active processes |
top | Shows real-time system resource usage and running processes |
pgrep | Searches for processes based on specified criteria and prints their process IDs |
pkill | Sends a signal to processes based on specified criteria to terminate them |
killall | Sends a signal to all processes with a specified name to terminate them |
pidof | Prints the process IDs of running processes based on their names |
nice | Sets the priority of a process |
renice | Changes the priority of running processes |
pstree | Displays running processes in a tree-like structure |
top | An Interactive command that shows real-time system resource usage and running processes |
htop | An Interactive process viewer that shows real-time system resource usage and running processes with additional features |
uptime | Shows the system uptime and load average |
free | Displays the system’s memory usage |
vmstat | Reports virtual memory statistics |
lsof | Lists open files and the processes that opened them |
iotop | Monitors and displays I/O usage by processes |
sar | Collects and reports system activity information, including CPU, memory, disk, and network usage |
at | Schedules commands or scripts to run at a specified time |
cron | Schedules recurring commands or scripts to run at specified intervals |
watch | Executes a command repeatedly and displays the output in real-time |
jobs | Lists the active jobs and their statuses in the current shell session |
fg | Brings a job to the foreground |
bg | Resumes a job in the background |
disown | Removes a job from the shell’s job control |
sleep | Suspends execution for a specified time |
time | Measures the time taken to execute a command |
systemctl | Controls system services, including starting, stopping, and restarting |
service | Controls system services, including starting, stopping, and restarting |
systemd | System and service manager for Linux |
shutdown | Shuts down or restarts the system |
VI Editor Commands
VI Editor Command | Description |
---|---|
i | Enters insert mode to start inserting text at the current cursor position |
a | Enters insert mode to start inserting text after the current cursor position |
o | Opens a new line below the current line and enters insert mode |
O | Opens a new line above the current line and enters insert mode |
dd | Deletes the current line |
yy | Copies the current line |
p | Pastes the copied or deleted text after the current line |
u | Undoes the last command or action |
/pattern | Searches forward for the specified pattern |
?pattern | Searches backward for the specified pattern |
n | Jumps to the next occurrence of the search pattern |
N | Jumps to the previous occurrence of the search pattern |
:w | Saves the changes made to the file |
:q | Quits the VI editor |
:q! | Quits the VI editor without saving changes |
:wq | Saves the changes made to the file and quits the VI editor |
: x | Saves the changes made to the file and exits the VI editor; no space between : and x |
:set number | Displays line numbers in the left margin |
:set nonumber | Hides line numbers in the left margin |
:%s/old/new/gc | Replaces all occurrences of ‘old’ with ‘new’ in the entire file with a confirmation |
:e filename | Replaces all occurrences of ‘old’ with ‘new’ in the entire file with a confirmation |
:r filename | Inserts the contents of another file at the current cursor position |
:w filename | Saves the current file with a different filename |
:set tabstop=n | Sets the number of spaces for a tab character |
:set autoindent | Enables automatic indentation |
:set nowrap | Disables line wrapping |
:set spell | Enables spell checking |
:set ruler: | Displays a ruler at the bottom of the editor |
:set background=dark | Sets the color scheme for dark backgrounds |
:set background=light | Sets the color scheme for light backgrounds |
:help | Displays the VI editor’s built-in help documentation |
Environment Variable Commands
Environmental Variable | Description |
---|---|
export | Sets an environmental variable |
echo | Displays the value of an environmental variable |
env | Displays all environmental variables |
set | Displays all variables, including environmental variables |
unset | Removes an environmental variable |
$PATH | Represents the search path for executable files |
$HOME | Represents the home directory of the current user |
$USER | Represents the username of the current user |
$PWD | Represents the present working directory |
$SHELL | Represents the current shell |
$LANG | Represents the current language setting |
$EDITOR | Represents the default text editor |
$TERM | Represents the terminal type |
$DISPLAY | Represents the display server |
$LOGNAME | Represents the login name of the current user |
Represents the location of the user’s mailbox | |
$HOSTNAME | Represents the hostname of the system |
$PS1 | Represents the primary prompt string |
$PS2 | Represents the secondary prompt string |
$PS3 | Represents the select prompt string |
$PS4 | Represents the selected prompt string |
$IFS | Represents the internal field separator |
$OLDPWD | Represents the previous working directory |
$UID | Represents the user ID of the current user |
$EUID | Represents the effective user ID of the current user |
$GROUPS | Represents the groups the current user belongs to |
$BASH_VERSION | Represents the version of the Bash shell |
$PWD | Represents the present working directory |
$OSTYPE | Represents the operating system type |
$HISTSIZE | Represents the maximum number of commands stored in the command history |
$HOSTNAME | Represents the hostname of the system |
$RANDOM | Represents a random number |
$SECONDS | Represents the number of seconds the script has been running |
$TZ | Represents the current time zone |
Package Management Linux Commands
Command | Description |
---|---|
apt-get install | Installs a package and its dependencies from the repository |
apt-get remove | Removes a package from the system |
apt-get update | Updates the package lists from the repositories |
apt-get upgrade | Upgrades all installed packages to the latest available versions |
apt-get dist-upgrade | Upgrades the system to the latest available version, including package dependencies |
apt-get autoremove | Removes automatically installed packages that are no longer needed |
apt-get clean | Clears the local repository of retrieved package files |
apt-cache search | Searches for packages based on keywords |
apt-cache show | Displays detailed information about a specific package |
apt-cache depends | Shows the dependencies of a package |
dpkg -i | Installs a .deb package file |
dpkg -r | Removes a package from the system |
dpkg -l | Lists all installed packages |
dpkg -L | Lists the files installed by a package |
dpkg -S | Searches for packages owning a specific file |
dpkg-reconfigure | Reconfigures an installed package |
yum install | Installs a package and its dependencies from the repository (used in CentOS/RHEL systems) |
yum remove | Removes a package from the system (used in CentOS/RHEL systems) |
yum update | Updates all installed packages to the latest available versions (used in CentOS/RHEL systems) |
yum search | Searches for packages based on keywords (used in CentOS/RHEL systems) |
dnf install | Installs a package and its dependencies from the repository (used in Fedora systems) |
Also Read: Best & Free Network Monitoring Tools for Linux
System Information Commands
Command | Description |
---|---|
uname | Displays system information such as kernel name, hostname, kernel release, etc |
hostname | Shows the name of the current host system |
lsb_release | Displays information about the Linux Standard Base and distribution-specific information |
cat /etc/os-release | Prints detailed information about the Linux distribution |
cat /proc/version | Shows the Linux kernel version and build information |
date | Displays the current date and time |
uptime | Shows the system uptime, load average, and number of users logged in |
whoami | Prints the username of the current user |
who | Displays information about currently logged-in users |
df | Shows disk space usage of file systems |
free | Displays memory usage and information |
top | Provides real-time information about system resource usage and processes |
ps | Shows information about active processes |
htop | Interactive process viewer that displays system resource usage and running processes with additional features |
iostat | Reports CPU, disk, and input/output statistics |
ifconfig | Displays network interface configuration |
netstat | Shows network statistics and active network connections |
route | Displays or manipulates the IP routing table |
lspci | Lists PCI devices connected to the system |
lsusb | Lists USB devices connected to the system |
Also Read: 10 Best & Free Screen Recorders for Linux/Ubuntu
Wrapping Up: Linux Commands Cheat Sheet
This sums up our handy Linux Commands Cheat Sheet for using Linux like a pro. However, this is not all. There are several more advanced commands which are more application related and need some more advancement in how you use Linux. Let’s try covering them up in our future blog post; let me know in the comment section if you need a more advanced Linux Commands Cheat Sheet.
Before You Leave
Get Our Prime Content Delivered to your Inbox for Free!! Join the Ever-Growing Community… Right Now.
Give this article a quick share,
I hope this Linux Commands Cheat Sheet came in handy to you. If I have missed out on a common Linux command, do let me know in the comment section. If you like this article, do give this a quick share on your social media handles, and do tag us. Also, join our Telegram channel, Facebook page, and Twitter to never miss a quick update.