Linux Commands Cheatsheet
Quick reference for essential Linux commands
A comprehensive quick reference guide covering the most commonly used Linux commands. From file management and text processing to networking and system administration, this cheatsheet helps you find the right command fast. Click on any command to read the full tutorial.
File Listing
View directory contents and file details.
| Command | Description |
|---|---|
ls | List directory contents |
ls -la | List all with details |
ls -lh | Human readable sizes |
ls -R | List recursively |
Navigation
Move between directories in the filesystem.
| Command | Description |
|---|---|
cd | Change directory |
cd .. | Go up one level |
cd ~ | Go to home |
cd - | Go to previous dir |
pwd | Print working directory |
pushd/popd | Directory stack |
Create & Delete
Create and remove files and directories.
| Command | Description |
|---|---|
mkdir | Create directory |
mkdir -p a/b/c | Create nested dirs |
touch | Create empty file |
rm | Remove file |
rm -rf dir | Remove dir recursively |
rmdir dir | Remove empty dir |
Copy & Move
Copy, move, and link files.
| Command | Description |
|---|---|
cp | Copy file |
cp -r src dest | Copy directory |
mv | Move or rename |
ln -s | Create symlink |
File Viewing
Display and browse file contents.
| Command | Description |
|---|---|
cat | Display contents |
less | View with pagination |
head | First N lines |
tail | Last N lines |
tail -f file | Follow changes |
File Search
Find files by name, type, or date.
| Command | Description |
|---|---|
find | Find files by criteria |
find . -name "*.txt" | Find by name |
find . -type d | Find directories |
locate | Quick search (db) |
Text Search
Search for patterns inside files.
| Command | Description |
|---|---|
grep | Search in file |
grep -r "text" dir | Search recursively |
grep -i "text" | Case insensitive |
grep -n "text" | Show line numbers |
grep -v "text" | Invert match |
File Info
Get information about files and commands.
| Command | Description |
|---|---|
file | Determine file type |
stat | Display file status |
type | Show command type |
which | Locate a command |
whereis | Locate binary/source |
basename | Strip directory path |
Permissions
Manage file permissions and ownership.
| Command | Description |
|---|---|
chmod | Change permissions |
chmod 755 file | Set rwxr-xr-x |
chmod +x file | Add execute |
chown | Change owner |
chgrp | Change group |
chattr | Change attributes |
umask | Set default perms |
User Info
Display information about users.
| Command | Description |
|---|---|
whoami | Current username |
id | User ID and groups |
who | Logged in users |
w | Who + what they do |
last | Login history |
User Management
Create, modify, and delete users.
| Command | Description |
|---|---|
useradd | Create user |
userdel | Delete user |
passwd user | Change password |
usermod | Modify user |
su | Switch user |
sudo | Run as root |
Group Management
Create and delete user groups.
| Command | Description |
|---|---|
groupadd | Create group |
groupdel | Delete group |
Process Viewing
Monitor running processes.
| Command | Description |
|---|---|
ps | List processes |
ps aux | All processes |
top | Interactive viewer |
htop | Better viewer |
pgrep | Find by name |
pidof | Find PID by name |
pstree | Process tree |
Process Control
Terminate and manage processes.
| Command | Description |
|---|---|
kill | Terminate process |
kill -9 PID | Force kill |
pkill | Kill by name |
killall name | Kill all by name |
timeout | Run with time limit |
Background Jobs
Run and manage background processes.
| Command | Description |
|---|---|
cmd & | Run in background |
bg | Background current |
fg | Foreground current |
jobs | List jobs |
nohup | Immune to hangups |
at | Schedule command |
Disk Usage
Check disk space and filesystem health.
| Command | Description |
|---|---|
df | Disk space |
du | Directory size |
du -h --max-depth=1 | Subdir sizes |
[free](/post/free-comma, “http”, “networking"nd-in-linux/) | Memory usage |
fdisk | Partition table |
fsck | Check filesystem |
Network
Configure and test network connections.
| Command | Description |
|---|---|
ip a | Show IP addresses |
ifconfig | Network interfaces |
ping | Test connectivity |
curl | Transfer data |
wget | Download file |
dig | DNS lookup |
SSH & Transfer
Secure remote access and file transfer.
| Command | Description |
|---|---|
ssh | SSH connection |
ssh -p 22 user@host | Custom port |
scp | Secure copy |
rsync | Sync files |
sftp | Secure FTP |
ftp | FTP transfer |
Network Tools
Advanced network diagnostics and scanning.
| Command | Description |
|---|---|
ss -tulpn | Listening ports |
netstat -tulpn | Listening ports |
lsof -i :80 | What uses port 80 |
nmap | Network scanner |
nc | Netcat utility |
tcpdump | Packet capture |
Archives
Create and extract compressed archives.
| Command | Description |
|---|---|
tar | Archive files |
tar -czvf a.tar.gz dir | Create tar.gz |
tar -xzvf a.tar.gz | Extract tar.gz |
gzip | Compress file |
gunzip | Decompress file |
zip -r a.zip dir | Create zip |
unzip a.zip | Extract zip |
Text Processing
Transform and manipulate text data.
| Command | Description |
|---|---|
sort file | Sort lines |
uniq file | Remove duplicates |
wc | Count lines/words |
cut | Cut columns |
tr | Translate chars |
paste | Merge lines |
Sed & Awk
Stream editing and pattern processing.
| Command | Description |
|---|---|
sed 's/old/new/g' | Find & replace |
sed -i 's/old/new/g' | In-place replace |
awk | Pattern processing |
awk '{print $1}' | Print 1st field |
awk -F: '{print $1}' | Custom delimiter |
Pipes & Redirection
Connect commands and redirect output.
| Command | Description |
|---|---|
tee | Read and write |
xargs | Build arguments |
diff | Compare files |
cmd > file | Redirect output |
cmd >> file | Append output |
cmd 2>&1 | Stderr to stdout |
System Info
Display system and hardware information.
| Command | Description |
|---|---|
uname -a | System info |
hostname | Show hostname |
uptime | System uptime |
date | Current date/time |
dmesg | Kernel messages |
history | Command history |
Timing & Scheduling
Schedule and time command execution.
| Command | Description |
|---|---|
time | Measure runtime |
watch | Run repeatedly |
[sleep](/post/how-to-us, “http”, “networking"e-linux-sleep-command-to-pause-a-bash-script/) | Delay execution |
at | Schedule once |
crontab -e | Schedule recurring |
System Control
Manage system power and settings.
| Command | Description |
|---|---|
shutdown | Shutdown system |
reboot | Restart system |
sysctl | Kernel parameters |
wall | Broadcast message |
export | Set env variable |
Package Management
Install and manage software packages.
| Command | Description |
|---|---|
apt | Debian packages |
apt install pkg | Install package |
apt update | Update package list |
rpm | RPM packages |
yum install pkg | RHEL/CentOS install |
dnf install pkg | Fedora install |
Kernel Modules
Load and manage kernel modules.
| Command | Description |
|---|---|
lsmod | List modules |
modprobe | Load module |
rmmod | Remove module |