Here is an extended and fully annotated version of the Linux Cheatsheet blog in Markdown, with:
Brief descriptions for each command
An Advanced Topics section covering cron, systemd, firewalld, SELinux, and more
Linux Cheat sheet
| Command | Description |
uname -a | Show kernel version and system architecture |
hostname | Display system hostname |
uptime | Show how long the system has been running |
whoami | Show the currently logged-in user |
id | Display user ID and group information |
lsb_release -a | Display Linux distribution info (Debian-based) |
cat /etc/os-release | Show OS information (universal method) |
File and Directory Management
| Command | Description |
ls -l | List files with details |
ls -a | Include hidden files |
pwd | Show current directory |
cd /path/to/dir | Change to target directory |
mkdir newdir | Create a new directory |
touch file.txt | Create an empty file |
cp source dest | Copy file or directory |
mv old new | Rename or move a file/directory |
rm file.txt | Delete a file |
rm -r dir | Recursively delete a directory and its contents |
File Permissions
| Command | Description |
chmod 755 file | Set permissions (owner: rwx, group/others: rx) |
chown user:group file | Change file ownership |
ls -l file | Show file permissions |
Shorthand permission examples:
chmod u+x script.sh
chmod go-rw file.txt
User Management
| Command | Description |
adduser arpit | Add new user |
passwd arpit | Set/change password for a user |
deluser arpit | Delete a user |
usermod -aG sudo arpit | Add user to the sudo group |
groups | Show current user's groups |
Package Management
Debian/Ubuntu
sudo apt update
sudo apt upgrade
sudo apt install <pkg>
sudo apt remove <pkg>
sudo apt purge <pkg>
Amazon Linux / RHEL / CentOS
sudo yum update
sudo yum install <pkg>
sudo yum remove <pkg>
Common Utility Installation
| Utility | Description | Debian-based | RHEL-based |
curl | Transfer data from URLs | sudo apt install curl | sudo yum install curl |
dnsutils | DNS tools: dig, nslookup | sudo apt install dnsutils | sudo yum install bind-utils |
git | Version control system | sudo apt install git | sudo yum install git |
htop | Interactive process viewer | sudo apt install htop | sudo yum install htop |
iproute2 | Modern networking commands | sudo apt install iproute2 | sudo yum install iproute |
jq | JSON processor | sudo apt install jq | sudo yum install jq |
net-tools | Legacy networking commands | sudo apt install net-tools | sudo yum install net-tools |
netcat | TCP/UDP networking tool | sudo apt install netcat | sudo yum install nc |
nmap | Network scanner | sudo apt install nmap | sudo yum install nmap |
python3 | Python interpreter | sudo apt install python3 | sudo yum install python3 |
pip3 | Python package manager | sudo apt install python3-pip | sudo yum install python3-pip |
screen | Terminal multiplexer | sudo apt install screen | sudo yum install screen |
telnet | Test TCP connectivity | sudo apt install telnet | sudo yum install telnet |
tmux | Terminal multiplexer | sudo apt install tmux | sudo yum install tmux |
tree | Show directory tree | sudo apt install tree | sudo yum install tree |
unzip | Extract .zip files | sudo apt install unzip | sudo yum install unzip |
wget | Download files from web | sudo apt install wget | sudo yum install wget |
zip | Compress files into .zip | sudo apt install zip | sudo yum install zip |
Process Management
| Command | Description |
ps aux | List all processes |
top | Real-time view of processes |
htop | Enhanced interactive process viewer |
kill PID | Terminate a process by PID |
kill -9 PID | Force kill a process |
pkill name | Kill processes by name |
jobs | List background jobs |
bg | Resume a job in the background |
fg | Bring background job to foreground |
Networking
| Command | Description |
ip a | Show IP addresses |
ip r | Show routing table |
ping host | Ping a host |
traceroute host | Trace route to a host |
netstat -tulnp | Show listening ports |
ss -tuln | Show socket status |
curl ifconfig.me | Show public IP address |
host domain.com | DNS lookup |
dig domain.com | Detailed DNS info |
Disk Usage
| Command | Description |
df -h | Show free space on mounted filesystems |
du -sh * | Show size of directories/files in current dir |
lsblk | Show block devices (disks, partitions) |
mount | Show mounted file systems |
Searching and Grep
| Command | Description |
find . -name "*.log" | Find files by name pattern |
grep "pattern" file.txt | Search for a pattern in a file |
grep -r "pattern" /dir | Recursive search |
locate filename | Quickly find files (needs updatedb) |
updatedb | Update locate database |
Compression and Archiving
| Command | Description |
tar -cvf archive.tar dir/ | Create a tar archive |
tar -xvf archive.tar | Extract tar archive |
tar -czvf archive.tar.gz dir/ | Create a compressed tar.gz |
tar -xzvf archive.tar.gz | Extract tar.gz |
zip archive.zip file | Create a zip archive |
unzip archive.zip | Extract a zip archive |
System Monitoring
| Command | Description |
uptime | Show system load and uptime |
free -h | Show memory usage |
vmstat | System performance metrics |
iostat | CPU and I/O usage (from sysstat package) |
sar -u 1 3 | CPU usage over 3 seconds |
| `dmesg | tail` |
Miscellaneous
| Command | Description |
alias ll='ls -la' | Create a custom shortcut |
history | Show command history |
!! | Run previous command again |
!100 | Run command number 100 from history |
Ctrl + R | Reverse search in history |
clear | Clear the terminal |
man ls | Show manual for ls |
which bash | Show full path of command |