Linux Cheatsheet

Comprehensive Linux command reference with 200+ commands. Search, filter by category, and click to copy.

Linux Cheatsheet

Essential Linux commands for everyday use

104

Commands

9

Categories

0

Favorites

25

Sections

Files
Navigation
pwd

Print working directory

cd [dir]

Change directory

cd ~

Go to home

cd -

Previous directory

cd ..

Go up one level

Files
Listing
ls

List contents

ls -la

Long format with hidden

ls -lh

Human-readable sizes

ls -lS

Sort by size

tree

Directory tree

Files
File Operations
cp [src] [dest]

Copy file

cp -r [src] [dest]

Copy directory

mv [src] [dest]

Move/rename

rm [file]

Remove file

rm -rf [dir]

Force remove dir

mkdir -p [path]

Create nested dirs

touch [file]

Create empty file

ln -s [target] [link]

Symbolic link

Files
Archives
tar -czvf archive.tar.gz [files]

Create gzipped tar

tar -xzvf archive.tar.gz

Extract gzipped tar

zip -r archive.zip [dir]

Create zip

unzip archive.zip

Extract zip

Text
Viewing
cat [file]

Display file

less [file]

View with paging

head -n 20 [file]

First 20 lines

tail -n 20 [file]

Last 20 lines

tail -f [file]

Follow file

Text
Searching
grep [pattern] [file]

Search pattern

grep -i [pattern] [file]

Case-insensitive

grep -r [pattern] [dir]

Recursive search

grep -n [pattern] [file]

Show line numbers

Text
Processing
sort [file]

Sort lines

uniq [file]

Remove duplicates

wc -l [file]

Count lines

sed 's/old/new/g' [file]

Replace text

awk '{print $1}' [file]

Print first column

Process
Viewing
ps aux

All processes

ps aux | grep [name]

Find process

top

Real-time viewer

htop

Interactive viewer

pgrep [name]

Get PID by name

Process
Managing
kill [pid]

Terminate process

kill -9 [pid]

Force kill

killall [name]

Kill by name

bg

Resume in background

fg

Bring to foreground

nohup [cmd] &

Run immune to hangups

System
System Info
uname -a

System info

hostname

Show hostname

uptime

System uptime

whoami

Current user

lscpu

CPU info

lsblk

Block devices

System
Disk Usage
df -h

Disk space

du -sh [dir]

Directory size

du -sh * | sort -hr

Sorted by size

ncdu

Interactive disk usage

System
Memory
free -h

Memory usage

vmstat

Virtual memory stats

Network
Network Info
ip a

Show IP addresses

ifconfig

Network config

hostname -I

Show local IPs

Network
Connectivity
ping [host]

Test connectivity

traceroute [host]

Trace route

nslookup [domain]

DNS lookup

dig [domain]

DNS lookup detailed

Network
Ports
netstat -tuln

Listening ports

ss -tuln

Listening ports (modern)

lsof -i :[port]

Process using port

Network
Transfer
curl [url]

Fetch URL

wget [url]

Download file

scp [file] [user]@[host]:[path]

Copy via SSH

rsync -avz [src] [dest]

Sync files

Permissions
File Permissions
chmod 755 [file]

Set rwxr-xr-x

chmod +x [file]

Add execute

chown [user] [file]

Change owner

chown -R [user] [dir]

Recursive chown

💡 r=4, w=2, x=1. Example: 755 = rwxr-xr-x

Permissions
Sudo
sudo [command]

Run as superuser

sudo -i

Root shell

su - [user]

Switch user

Users
User Management
useradd -m [user]

Create user with home

userdel -r [user]

Delete user with home

usermod -aG [group] [user]

Add to group

passwd [user]

Set password

Users
Groups
groupadd [group]

Create group

groups [user]

Show user groups

Packages
APT (Debian/Ubuntu)
apt update

Update package list

apt upgrade

Upgrade packages

apt install [pkg]

Install package

apt remove [pkg]

Remove package

apt search [pkg]

Search packages

Packages
YUM/DNF (RHEL)
yum install [pkg]

Install package

dnf install [pkg]

Install (Fedora)

Advanced
Find
find [dir] -name [pattern]

Find by name

find [dir] -type f

Find files only

find [dir] -mtime -7

Modified in 7 days

find [dir] -size +100M

Larger than 100MB

Advanced
Services (systemd)
systemctl start [service]

Start service

systemctl stop [service]

Stop service

systemctl status [service]

Service status

systemctl enable [service]

Enable at boot

journalctl -u [service]

Service logs

Advanced
Cron
crontab -e

Edit cron jobs

crontab -l

List cron jobs

💡 Format: minute hour day month weekday command

Quick Reference

List

ls -la

Find

find . -name "*"

Search

grep pattern file

Disk

df -h

Process

ps aux

About Linux Commands

Linux commands are the foundation of system administration and development. This cheatsheet covers essential commands for file management, text processing, process control, networking, and more.