Ashwin S.07 Jul 2022Updated 22 May 2026Linux & Sysadmin7 min read

100+ Linux Commands Cheat Sheet (Beginner to Advanced)

On this page

You can achieve virtually anything on a Linux operating system using a command. Whether you want to send a file to the printer, set up your system firewall, or edit a file without even opening it; you can do it all directly from the terminal.

There're thousands of commands available on any Linux system and more handed to you whenever you install new software or packages. It’s a common misconception amongst beginners that you have to cram all of these commands in order to be considered an expert, but in reality, you only need to know a small subset of commands to become a proficient Linux administrator. Find out why using Linux for business is benficial.

In this article, we'll be sharing 100+ such commands across different categories along with a downloadable cheat sheet. Read our Grep command in Linux guide.

Basic Commands

Command

Description

CommandDescription
ls
Show all files and directories present in the working directory
CommandDescription
ls -l
Show all files and directories along with details like ownership, size, and when they were last modified
CommandDescription
ls -t
Sort the output of ls by last modified date
CommandDescription
pwd
List the path of the current working directory
CommandDescription
cd directory
Switch to a different working directory
CommandDescription
cd ..
Move up one directory level
CommandDescription
cd /
Switch to the root directory
CommandDescription
clear
Wipe out all the text from the terminal screen
CommandDescription
history
Print out all the previously executed commands in the current session
CommandDescription
touch filename
Create a new file
CommandDescription
vi filename
Open a file for editing
CommandDescription
cat filename
Display the contents of a file
CommandDescription
hostnamectl
List system information, including kernel, release, architecture, and virtualization etc.
CommandDescription
ifconfig
Show the network interfaces, IP addresses, and MAC address of the system
CommandDescription
date
Print the current system date and time
CommandDescription
top
List all the running processes on the system
CommandDescription
free -m
Show memory usage stats
CommandDescription
head filename
Display the first 10 lines of a file
CommandDescription
tail filename
Display the last 10 lines of a file
CommandDescription
mv file /new/file/path
Move the file to a different location
CommandDescription
mv filename new_filename
Rename a file
CommandDescription
cp filename new_filename
Copy a file
CommandDescription
man command_name
List helpful information regarding a command
CommandDescription
rm filename
Delete a file
CommandDescription
rm –rf directory_name
Remove a directory and its contents
CommandDescription
sudo
For regular users to run commands with elevated privileges
CommandDescription
mkdir directory_name
Create a new directory
CommandDescription
kill pid
Kill a process using its process ID
CommandDescription
reboot
Restart the system
CommandDescription
shutdown –h now
Turn off the system

Networking Commands

Command

Description

CommandDescription
dig domain_name
Show the DNS related information of the given domain name
CommandDescription
dig -x host
Perform a reverse lookup for a host
CommandDescription
host domain_name
Perform DNS lookup of the given domain name which prints out the IP address
CommandDescription
whois domain_name
For more information about a domain
CommandDescription
ping ip
Check the connectivity between your host and the given IP address
CommandDescription
ssh username@ip
To securely log in as the specified user on another server
CommandDescription
wget file
Download a file
CommandDescription
wget -c file
Continue a stopped download
CommandDescription
traceroute domain_name
Trace the route a packet will take when travelling from your machine to a host
CommandDescription
telnet domain_name port
Connect to a remote host on a specific port
CommandDescription
netstat –pnltu
Display all currently listening ports
CommandDescription
route
Display the routing table for your machine
CommandDescription
arp
View the contents of the ARP (address resolution protocol) table
CommandDescription
cat /etc/resolv.conf
See the DNS servers that your machine is currently using
CommandDescription
tcpdump -i eth1 'port 80'
Log and monitor all incoming traffic on port 80
CommandDescription
nmap ip
Network discovery of the given IP. Find out whether the host is up, which ports are open etc.

Command

Description

CommandDescription
locate keyword
Search for a file or directory in a pre-compiled cache. Much faster than find but many not show all results
CommandDescription
find keyword
Search for a file or directory in the real system. Much slower than locate but is always up-to-date
CommandDescription
find /home -name *.ext
Search for the given extension in the /home directory and all its sub-directories
CommandDescription
find / -type f ! -perm xxx
List all files that don’t have the specified permission
CommandDescription
find / -perm /u=r
Display all the read-only files
CommandDescription
grep keyword filename
Search for the specified keyword/pattern in the given file
CommandDescription
grep keyword *
Search for the specified keyword/pattern across all files in the current directory
CommandDescription
grep -i keyword *
To ignore case while searching
CommandDescription
grep -r keyword *
Perform a recursive search, i.e. include the sub-directories in the search
CommandDescription
grep -x 'what to match' *
Print all the lines where a match was found
CommandDescription
grep -c keyword *
Count the number of matches

Permissions Commands

Command

Description

CommandDescription
chmod xxx filename
Assign the specified permissions to a file
CommandDescription
chmod –R xxx directory
Assign the specified permissions to a directory, and all its sub-directories
CommandDescription
chmod –x filename
Remove the execution permissions from a file
CommandDescription
chown username filename
Change the ownership of the specified file
CommandDescription
chown username:groupname filename
Change the ownership and the group ownership of a file
CommandDescription
chown username:groupname filename1 filename2 filename3
Change the ownership and the group ownership of multiple files
CommandDescription
chown --from=bob alice filename
Change the ownership of a file only if it’s owned by a specific user (added after --from=)
CommandDescription
chown -h usergroup symbolic_link
Forcefully change the owner and group of a symbolic link

Storage Commands

Command

Description

CommandDescription
df –h
List storage related information of all partitions, including overall size, free space, and used space etc.
CommandDescription
mount
unmount
Mount or unmount an ISO file or a storage device
CommandDescription
du -h /home/directory_name
Find the directory size in a human readable format
CommandDescription
du -sh /home/directory_name
To get the total size of a directory
CommandDescription
du -ah --exclude='*.xxx' /home/directory_name
Display the disk usage of all files in a directory, excluding files with the given extension
CommandDescription
du -ha --time /home/directory_name
Display disk usage of a directory by modification time
CommandDescription
fdisk -­l
Show disk size along with partitioning information
CommandDescription
sudo du -x / | sort -nr | head -20
List the top 20 directories that are overconsuming resources

User Management Commands

Command

Description

CommandDescription
adduser username
Add a new user
CommandDescription
userdel -r 'username'
Delete a user
CommandDescription
passwd -l 'username'
Change the password of a user
CommandDescription
whoami
See the currently logged in user
CommandDescription
usermod -c 'This user will be deleted tomorrow' username
To add a comment to a user account
CommandDescription
cat /etc/passwd
Display a list of all users with additional info
CommandDescription
usermod -d /home/test username
Change the home directory of a user
CommandDescription
sudo deluser username group_name
Remove a user from a group
CommandDescription
usermod -a -G group_name username
Add a user to a group
CommandDescription
groupadd group_name
Create a new group
CommandDescription
groupdel group_name
Delete a group
CommandDescription
id
Display the user ID, group ID, and groups for the current user

Archive Commands

Command

Description

CommandDescription
tar -cvf archive.tar filename.txt
Compress a file into a tar archive
CommandDescription
tar -tvf archive.tar
Display the contents of a tar archive
CommandDescription
tar -xvf archive.tar filename.txt
Extract a single file out of a tar archive
CommandDescription
zip archive.zip file1.txt file2.html file3.jpg
Create a zip archive using multiple files
CommandDescription
zip -u archive.zip filename.txt
Add a file to an already zipped file
CommandDescription
zip -d archive.zip filename.txt
Delete a file from a zip archive
CommandDescription
unzip archive.zip
Unzip a zip archive
CommandDescription
unzip archive.zip -d /directory_name
Unzip a zip archive to a specific directory
CommandDescription
tar xf archive
Extract archive of any type
CommandDescription
gzip filename
Compress a file and add the .gz extension to it. This will delete the original file
CommandDescription
gzip -c filename > archive.gz
Create a new compressed .gz file, preserving the original

Advanced Commands

Command

Description

CommandDescription
ps –ef | grep process_name
Check whether a specific process is running
CommandDescription
netstat –pnltu | grep port
Check whether a specific port is open
CommandDescription
history | grep keyword
Search for something in the history
CommandDescription
ip r
Display the IP address of the default gateway
CommandDescription
ssh-keygen
Generate SSH keys to allow public key based secure login
CommandDescription
scp filename user@ip:/home/location
Securely copy a file to a remote host
CommandDescription
find / -type f -perm 777 -print -exec chmod xxx {} \;
Find all the files that have 777 permissions, and modify them to xxx
CommandDescription
sed -i 's/CONTENT_TO_REPLACE/CONTENT_TO_REPLACE_IT_WITH/g' filename
Replace the specified content in a file with something else
CommandDescription
tcpdump -nnvvS src SRC_IP and dst port xxxx
Monitor all traffic emerging from a certain IP and going towards a certain port
CommandDescription
traceroute domain_name -q 5
Send 5 packets per hop while tracing the route to the given domain name

Downloadable Cheat Sheet

Download the 2560x1440 wallpaper cheat sheet for easy reference.

Linux Commands Cheat Sheet

Download the Cheat Sheet
Avatar for Ashwin S.

Ashwin S.

The Author

Ashwin is a content specialist at HostAfrica, where he's been crafting clear, authoritative copy since 2021. With a background in digital marketing and a passion for impactful storytelling, he turns complex ideas into trustworthy, engaging content. Ashwin writing helps our audience navigate web hosting and cloud solutions with confidence.