Have you ever sat in front of a Linux terminal and felt completely lost? You’ve probably tried most linux commands cheatsheets online, and they are either too shallow to be useful or too technical to understand.
Maybe you just needed to run a simple command to fix an issue, but instead, you found yourself googling endlessly, copying snippets from forums, hoping they’d work.
Or perhaps you’ve used Linux for a while but keep forgetting the exact syntax for critical commands?
It’s undeniable that Linux commands are powerful, but they can also be overwhelming.
There are hundreds of commands, each with dozens of options and variations, and a single typo can completely change the outcome or even break your system.
This could leave you stuck in a frustrating cycle of trial and error.
The good news is, with the right guide, you can find the commands you need, understand what they do, and even combine them to perform complex tasks.
That’s why we’ve put together this linux commands cheatsheet. This guide covers:
- The essential Linux commands you need to know.
- Clear explanations of what each command does and why it matters.
- Examples of each command in action.
- Advanced tips and shortcuts to boost your productivity.
This cheat sheet is designed for everyone, from a beginner setting up their first Linux machine to a seasoned sysadmin who just needs a reliable reference.
Let’s dive in.
Linux Commands Cheatsheet Summary Table
In a hurry? Check out this quick reference table
| Category | Command | Purpose / When to Use It | Example Usage |
| Navigation | pwd | Show full path of current directory. | pwd |
| ls | List files and folders. Use -l for details, -a for hidden files. | ls -la | |
| cd | Change directories. cd .. to go up one level. | cd /var/www | |
| tree | Visualize folder structure as a tree. | tree -L 2 | |
| File Management | touch | Create empty file or update timestamp. | touch notes.txt |
| mkdir | Create new folder(s). Use -p for nested folders. | mkdir -p projects/2025/july | |
| cp | Copy files/folders. Use -r for recursive copy. | cp -r site/ /backup/ | |
| mv | Move or rename files/folders. | mv draft.txt final.txt | |
| rm | Delete files/folders. Use -i to confirm, -rf to force delete recursively. | rm -rf /tmp/old/ | |
| Move hidden files | Safely move hidden files without affecting . or … | mv .[!.]* /dest/ | |
| Viewing Files | cat | Display contents of a small file. | cat README.md |
| less | View large files one page at a time. | less /var/log/syslog | |
| head | Show first lines of a file. | head -n 20 file.log | |
| tail | Show last lines of a file, -f for real-time logs. | tail -f error.log | |
| nano | Beginner-friendly text editor. | nano /etc/hosts | |
| vim | Advanced text editor for power users. | vim server.conf | |
| Searching | find | Locate files by name, type, age, size. | find /home -name ‘*.sql’ |
| grep | Search inside files for specific text. | grep -n “error” file.log | |
| locate | Quickly find files using an indexed database. | locate file.txt | |
| Permissions | ls -l | View permissions and ownership of files. | ls -l |
| chmod | Change permissions. | chmod 644 index.html | |
| chown | Change file owner and group. | chown user:group file.txt | |
| chgrp | Change only the group of a file. | chgrp devs script.sh | |
| umask | Set default permissions for new files. | umask 022 | |
| Networking | ping | Test network connectivity and response time. | ping -c 4 8.8.8.8 |
| ip addr | Show network interfaces and IP addresses. | ip addr show eth0 | |
| ss | View active connections and listening ports. | ss -tuln | |
| curl | Fetch data from URLs, check APIs or endpoints. | curl -I https://site.com | |
| wget | Download files from the internet. | wget https://site.com/file.zip | |
| dig | Query DNS records for troubleshooting. | dig example.com | |
| traceroute | Trace network path to a host. | traceroute google.com | |
| scp | Securely copy files between systems. | scp file.tar user@host:/backup/ | |
| rsync | Sync files efficiently between systems. | rsync -avz dir/ user@host:/dir/ | |
| Processes | ps | View current running processes. | `ps aux |
| top | Real-time interactive process monitoring. | top | |
| kill | Terminate process by PID. | kill 1234 | |
| killall | Terminate all processes by name. | killall nginx | |
| jobs | List backgrounded jobs. | jobs | |
| bg | Resume job in background. | bg %1 | |
| fg | Bring job to foreground. | fg %1 | |
| Users & Groups | whoami | Show current logged-in user. | whoami |
| id | Display user and group IDs. | id alice | |
| useradd | Create a new user. | useradd -m username | |
| passwd | Set or change a password. | passwd username | |
| usermod | Modify user account settings. | usermod -aG group username | |
| userdel | Delete a user account. | userdel -r username | |
| groups | Show groups a user belongs to. | groups username | |
| sudo | Run a single command as another user (root). | sudo apt update | |
| su | Switch to another user account. | su – | |
| System Monitoring | df -h | Show disk space usage in human-readable format. | df -h |
| du -sh | Show folder size summary. | du -sh /var/www | |
| free -h | Show memory usage stats. | free -h | |
| uptime | Show how long system has been running. | uptime | |
| iostat | Show disk I/O stats (from sysstat). | iostat | |
| vmstat | Show CPU, memory, I/O in real-time. | vmstat 1 | |
| sar | Historical performance data (sysstat). | sar -u 1 5 | |
| smartctl | Check disk health and SMART attributes. | sudo smartctl -a /dev/sda | |
| Archiving & Backups | tar | Archive and compress files. | tar -czvf backup.tar.gz folder/ |
| gzip / gunzip | Compress or decompress individual files. | gzip file / gunzip file.gz | |
| zip / unzip | Compress/extract ZIP files. | zip -r site.zip site/ | |
| rsync | Efficiently sync backups or files. | rsync -avz /src /backup/ |
Need more details about what all these commands do? Read on below.
1. Navigation (where you are and how you move)
- pwd — Print working directory.
Displays the full path of the directory you’re currently in, starting from the root (/).
Shows the full path from root (/) to your current folder. Use it whenever you’re unsure where you are before running commands that modify files.
Example:
pwd
# /home/alice/projects/site
- ls — List directory contents.
Lists files and directories in the current folder, with optional flags for more details or hidden files.
Lists visible files by default. Use flags: -l for details (permissions, owner, size, date), -a to show hidden files (those starting with .), -h for human-readable sizes.
Examples:
ls -l
ls -la # detailed list including hidden files
- cd — Change directory.
Moves you between directories in the filesystem.
Move into folders: cd folder, up one level cd .., to home cd ~ or simply cd.
Examples:
cd /var/www
cd ..
cd ~
- Tree
Displays the folder structure as a visual tree, making it easier to see nested files and directories.
(if installed) prints a visual directory tree:
tree -L 2
- Navigation is at the heart of Linux, especially when working on complex servers or cloud environments where directory structures can be massive.
- Using pwd regularly keeps you aware of where you are, which helps prevent mistakes like deleting files in the wrong folder.
- Combining cd with autocomplete (Tab key) makes movement much faster,
- tree provides a visual map when you need to understand the structure quickly.
2. File & directory management (create, copy, move, delete)
- touch — create an empty file or update timestamp.
Creates a new, empty file or updates the timestamp of an existing file without changing its contents.
touch notes.txt
- mkdir — make directories.
Creates one or more new folders, and with -p, creates nested folders in one step.
-p creates nested directories in one go.
mkdir -p projects/2025/july
- cp — copy files/directories.
Copies files or directories to another location, with optional flags to preserve attributes or copy recursively.
-r for recursive (folders), -p to preserve timestamps/permissions, -i to prompt before overwrite.
cp file.txt file.bak
cp -r site/ /backups/site/
- mv — move or rename.
Moves files or directories to a new location or renames them if given a new name.
Same syntax — use a directory as a destination to move, or a filename to rename.
mv draft.txt final.txt # rename
mv final.txt /var/www/html/ # move
- Moving hidden files:
Hidden files start with a dot (.) and require special wildcards to move safely without affecting . or …
To move all hidden files safely (excluding . and ..) use:
mv .[!.]* /destination/
If you want both visible and hidden files:
mv * .[!.]* /destination/
- rm — remove files/directories (dangerous).
Deletes files or folders permanently, with no trash or undo option, so use with extreme caution.
rm file deletes a file. rm -r folder/ deletes a folder and everything inside. -i prompts for confirmation; -f forces. No trash. Always ls first and prefer -i for safety.
Examples:
rm -i *.tmp
rm -rf /tmp/oldbackup # dangerous — double-check path
- File management commands are some of the most commonly used in Linux.
- The real danger comes from recursive deletions using rm -rf, which can wipe out an entire directory tree in seconds.
- Always double-check paths with pwd and ls before using destructive commands.
- Consider using version control like Git for critical files so you can easily roll back if something goes wrong.
3. Viewing and editing files
- cat — display small files or concatenate.
Outputs the contents of a file to the terminal, or combines multiple files into one.
cat README.md
- less — view large files page by page (preferred).
Opens files one page at a time, making it easier to scroll through large files without loading them fully into memory.
Use /pattern to search, n to next, q to quit.
less /var/log/syslog
- head / tail
head shows the first lines of a file, while tail shows the last lines — useful for previews and logs.
tail -f follows a growing log.
head -n 20 file.log
tail -n 50 file.log
tail -f /var/log/nginx/error.log
- Editors — nano and vim.
These are text editors for modifying files directly in the terminal, with nano being beginner-friendly and vim more advanced.
nano is beginner-friendly. vim is powerful once you learn modes. Quick open:
nano /etc/hosts
vim server.conf
- When troubleshooting, knowing how to quickly view logs is critical.
- less is more efficient than opening logs in an editor because it doesn’t load the entire file into memory.
- For real-time monitoring, tail -f is essential.
- If you need to make changes, start with nano for simplicity. As you gain confidence, learning vim can greatly improve your speed and efficiency.
4. Searching & locating
- find — locate files by name, type, age, size.
Searches your filesystem for files or folders based on criteria like name, type, size, or date modified.
Start from a path to limit the search (faster than /). Useful flags: -name, -type f|d, -mtime, -size.
Examples:
find /home -name ‘*.sql’
find . -type d -name ‘cache’
find /var/log -mtime -7 # files modified in last 7 days
find / -size +100M # files larger than 100MB
- grep — search inside files (text matching).
Finds specific text patterns within files, making it essential for log analysis and troubleshooting.
-r recursive, -i case-insensitive, -n show line numbers. Use with find to search particular files.
Examples:
grep -n “error” /var/log/nginx/error.log
grep -ri “OutOfMemory” /opt/app/logs/
find /home -name “*.log” -exec grep -H “Exception” {} \;
- locate
Uses a pre-built index to quickly search for files, though results may be outdated until you refresh with updatedb.
Uses an index (faster but may be stale); run updatedb to refresh.
- Search tools like find and grep are lifesavers when dealing with large systems or codebases. Pairing them together makes it easy to pinpoint issues quickly, such as finding which file contains a specific configuration error.
- Remember that locate is lightning fast but relies on a pre-built database, so it’s perfect for general file searches but less ideal for immediate troubleshooting.
5. Permissions & ownership (security basics)
- ls -l
Lists files with detailed information, including permissions, ownership, and modification dates.
Shows permission bits:
-rw-r–r– 1 alice www 4096 Aug 1 file.txt
- chmod — change permissions.
Adjusts read, write, and execute permissions for file owners, groups, and others.
Two modes: symbolic (u, g, o, a) or numeric (e.g., 755, 644).
Examples:
chmod 644 index.html # owner rw, group r, others r
chmod u+x script.sh # add execute for owner
chmod -R 750 /var/www # recursive
- chown — change owner and group.
Changes the owner and/or group of a file or directory.
chown alice:developers file.txt
chown -R www-data:www-data /var/www/html
- chgrp — change group only.
Changes the group ownership of a file or directory without affecting the owner.
chgrp devops deploy.sh
- Umask
Sets default permissions for newly created files and directories.
Controls default permissions for newly created files; you usually set this in shell profiles.
Proper permissions are necessary for security and collaboration. A misconfigured chmod or chown can either expose sensitive data or lock out legitimate users.
When working on shared servers, take the time to understand group permissions and test changes in a safe environment before applying them system-wide.
6. Networking & transfers
- Ping
Tests whether a network connection to another host is working and measures response time.
ping -c 4 8.8.8.8
- ip addr / ifconfig
Displays network interfaces and their IP addresses, with ip being the modern replacement for ifconfig.
ip addr show eth0
- netstat / ss
Lists open network connections and listening ports, with ss as the faster, modern alternative.
ss -tuln
netstat -tulpn | grep :80
- curl / wget
Fetches content from URLs, with curl being more versatile and wget ideal for simple downloads.
curl -I https://example.com # show headers
wget https://example.com/file.zip
- nslookup / dig
Queries DNS records to troubleshoot domain name resolution.
dig +short example.com
nslookup example.com
- Traceroute
Shows the path your network traffic takes to reach a host, hop by hop.
traceroute google.com
- scp / sftp / rsync
Copies files securely between systems, with rsync optimized for efficient synchronization.
scp backup.tar.gz user@host:/backups/
rsync -avz site/ user@host:/var/www/site/
- Networking commands are essential for troubleshooting connectivity issues.
- A good workflow starts with ping to check reachability, then traceroute to see where the connection breaks.
- Use ss to confirm which services are listening and curl to verify web servers are responding correctly.
- For backups, rsync is your friend because it only transfers changed files, saving time and bandwidth.
7. Process management (what’s running and how to control it)
- Ps
Displays running processes and their details like PID, user, and memory usage.
Snapshot of processes. ps aux shows all processes.
ps aux | grep nginx
- Top
Provides a real-time, interactive view of system processes and resource usage. Real-time process monitor; htop is a friendlier interactive version (install it).
- kill — terminate by PID.
Stops a specific process using its PID (process ID). Start with graceful kill PID (SIGTERM), use kill -9 PID (SIGKILL) only if necessary.
- Killall
Stops all processes matching a specific name. Kills by process name:
killall nginx
- Job control:
Manages processes started in your shell, allowing you to pause, resume, or foreground them.
For tasks started in your shell:
- jobs — list backgrounded jobs
- bg — resume stopped job in background
- fg — bring a job to foreground
Examples:
# Start a process, suspend with Ctrl+Z, then:
jobs
bg %1
fg %1
- Avoid kill -9 unless the process won’t stop; it prevents cleanup steps.
- Process management is critical for maintaining server health.
- top and htop let you identify which processes are hogging resources in real-time.
- Gracefully stopping services avoids data corruption, especially for databases or web servers.
- When troubleshooting, always start with observation before taking action.
8. Users & groups (multi-user safety)
- Whoami
Shows which user account is currently logged in.
whoami
- Id
Displays user ID (UID), group ID (GID), and group memberships.
id alice
- Create/modify users:
Commands for adding, updating, and deleting user accounts.
- useradd -m username — create with home dir
- passwd username — set password
- usermod -aG group username — add to group
- userdel -r username — delete and remove home
- Groups
Shows all groups a specific user belongs to.
Displays a user’s groups.
- sudo vs su:
sudo runs a command as another user (often root) while su switches to another user session entirely.
- sudo runs a single command with elevated privileges (preferred).
- su – switches user accounts (including root).
Always favor sudo for safer auditability.
Linux was designed for multi-user environments. Understanding how to manage accounts and groups is vital for security.
Always create separate user accounts for different roles instead of sharing logins. This protects the system and also makes it easier to track changes through logs.
9. System monitoring & health
- df -h
Shows available disk space across mounted filesystems in a human-readable format.
df -h
- du -sh path
Displays the size of a specific folder or file.
du -sh /var/www/*
- free -h
Shows memory usage statistics, including free, used, and swap memory.
free -h
- Uptime
Displays how long the system has been running and its load averages.
uptime
- I/O & CPU tools:
These commands help track CPU usage, disk I/O, and system performance.
- iostat (from sysstat) shows disk I/O stats.
- vmstat 1 shows CPU, memory, I/O in intervals.
- sar stores historical performance (install sysstat).
- Disk health:
Checks hardware disk health through SMART attributes.
smartctl (from smartmontools) to check SMART attributes:
sudo smartctl -a /dev/sda
Regular monitoring prevents outages and performance bottlenecks. For production servers, automate these checks with monitoring tools like Nagios or Prometheus.
Tracking trends over time helps you forecast when to upgrade resources or replace failing hardware.
10. Archiving, compression & backups
- tar — the archiver
Bundles files into a single archive and optionally compresses them.
- tar -cvf archive.tar dir/ create
- tar -xzvf archive.tar.gz extract (gzip)
- tar -cjvf archive.tar.bz2 dir/ bzip2
Examples:
tar -czvf site-backup-2025-09-16.tar.gz /var/www/site
tar -xvf archive.tar
- gzip / gunzip
Compresses or decompresses individual files using the Gzip algorithm.
gzip logfile
gunzip logfile.gz
- zip / unzip
Compresses and extracts files in the popular ZIP format for cross-platform use.
zip -r site.zip site/
unzip site.zip -d /tmp/site
Best practice:
- Automating backups protects your data from loss due to hardware failure or accidental deletion.
- Automate backups (files and databases) and store copies off-site. Use rsync to sync backups efficiently.
- Always test backups by doing a trial restore to ensure they work.
- Store multiple copies in different locations, such as a local drive, cloud storage, and a secure external backup, to minimize the risk of catastrophic data loss.
Final words
Now tha you have a better feel of the most popular linux commands, the next step is to start using them. Start by pick three tasks and practice them on a non-production system:
- Create a directory structure, add files, compress it with tar -czvf, move it via scp.
- Simulate a runaway process with a small script, inspect it using ps/top, then stop it safely with kill.
- Set up a user with useradd -m, add it to a group, and adjust file ownership with chown and permissions with chmod.
Mastering these commands turns the terminal into a reliable tool for running, securing, and scaling systems.
Domain SearchInstantly check and register your preferred domain name
Web Hosting
cPanel HostingHosting powered by cPanel (Most user friendly)
KE Domains
Reseller HostingStart your own hosting business without tech hustles
Windows HostingOptimized for Windows-based applications and sites.
Free Domain
Affiliate ProgramEarn commissions by referring customers to our platforms
Free HostingTest our SSD Hosting for free, for life (1GB storage)
Domain TransferMove your domain to us with zero downtime and full control
All DomainsBrowse and register domain extensions from around the world
.Com Domain
WhoisLook up domain ownership, expiry dates, and registrar information
VPS Hosting
Managed VPSNon techy? Opt for fully managed VPS server
Dedicated ServersEnjoy unmatched power and control with your own physical server.
SupportOur support guides cover everything you need to know about our services








