Linux cheatsheet

Senior Backend Engineer
Search for a command to run...

Senior Backend Engineer
No comments yet. Be the first to comment.
Install Redis cli $ brew install redis-cli General PING # Test connection, returns PONG AUTH <password> # Authenticate with password SELECT <db> # Switch to a specific database (default is 0) DBSIZE # Get total nu...

InfluxDB 3 client: influxctl influxctl is the official command-line tool for managing and interacting with InfluxDB 3 clusters. Think of it as your Swiss Army knife for database setup, bucket management, and query execution. This cheatsheet gives you...
1 Year on LeetCode: Lessons, Struggles, and Growth Exactly one year ago, I made a commitment — to open LeetCode daily, without excuses, and start solving problems that once made me uncomfortable. What started as a casual attempt to improve my DSA ski...

Git Cheatsheet – The Ultimate Guide Whether you're just getting started with Git or you're a seasoned developer, having a handy cheatsheet saves time and avoids Googling the same commands over and over again. This guide is organized into Basic, Inter...

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
| 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) |
| 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 |
| 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 # Add execute to user
chmod go-rw file.txt # Remove read/write from group and others
| 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 |
sudo apt update # Update package index
sudo apt upgrade # Upgrade installed packages
sudo apt install <pkg> # Install package
sudo apt remove <pkg> # Remove package
sudo apt purge <pkg> # Remove including config files
sudo yum update # Update packages
sudo yum install <pkg> # Install package
sudo yum remove <pkg> # Remove package
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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` |
| 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 |