DevOpsil
Linux46 commands

Linux Commands Cheat Sheet

Essential Linux commands for files, processes, networking, disk management, users, and system administration.

Files & Directories

CommandDescription
ls -la
List all files with details
find / -name "*.log" -mtime -1
Find files modified in last 24h
du -sh /var/*
Disk usage per directory
df -h
Show disk space usage
tar czf archive.tar.gz /path/to/dir
Create compressed archive
tar xzf archive.tar.gz
Extract archive
rsync -avz src/ dest/
Sync files with progress
ln -s /target /link
Create symbolic link
chmod 755 file
Set file permissions
chown user:group file
Change file ownership

Process Management

CommandDescription
ps aux
List all running processes
ps aux | grep <name>
Find process by name
top
Real-time process monitor
htop
Interactive process viewer
kill <pid>
Terminate process by PID
kill -9 <pid>
Force kill process
nohup command &
Run command immune to hangup
lsof -i :8080
Find process using port

Networking

CommandDescription
ip a
Show IP addresses
ss -tulnp
List listening ports with PIDs
curl -I https://example.com
Fetch HTTP headers
dig example.com
DNS lookup
traceroute example.com
Trace route to host
netstat -rn
Show routing table
iptables -L -n
List firewall rules
wget -q -O - https://example.com
Download to stdout

Text Processing

CommandDescription
grep -rn "pattern" /path/
Recursive search with line numbers
sed -i 's/old/new/g' file
Find and replace in file
awk '{print $1, $3}' file
Print specific columns
sort file | uniq -c | sort -rn
Count and sort occurrences
tail -f /var/log/syslog
Follow log file
wc -l file
Count lines in file
cut -d',' -f1,3 file.csv
Extract CSV columns

Users & Permissions

CommandDescription
whoami
Show current user
id
Show user ID and groups
useradd -m -s /bin/bash <user>
Create user with home dir
usermod -aG sudo <user>
Add user to sudo group
passwd <user>
Change user password
su - <user>
Switch user
visudo
Edit sudoers safely

System Info

CommandDescription
uname -a
Kernel and OS info
uptime
System uptime and load
free -h
Memory usage
cat /etc/os-release
OS version details
lscpu
CPU info
dmesg | tail -20
Recent kernel messages