Linux CLI Cheat Sheet
The commands sysadmins and network engineers actually use—file ops, process management, networking, and troubleshooting.
2 min read·By Arun R Kaushik
File & Directory Operations
ls -lah # list all files with details
cd /path/to/dir # change directory
pwd # print working directory
cp -r src/ dst/ # copy recursively
mv old new # move/rename
rm -rf dir/ # remove directory (careful!)
find . -name "*.log" # find files by name
chmod 644 file # set permissions
chown user:group file # change ownership
Viewing & Editing Files
cat file.txt # print whole file
less file.txt # paginated view
head -n 20 file.txt # first 20 lines
tail -f /var/log/syslog # follow log live
grep -ri "error" . # recursive case-insensitive search
Process Management
ps aux # list all processes
top # live process viewer
htop # nicer live viewer (if installed)
kill -9 <pid> # force kill a process
systemctl status nginx # check service status
systemctl restart nginx # restart a service
journalctl -u nginx -f # follow service logs
Networking
ip addr show # show interfaces/IPs
ip route show # show routing table
ss -tulpn # show listening ports + processes
ping -c 4 host # send 4 ICMP echo requests
traceroute host # trace path to host
curl -I https://host # fetch headers only
dig host # DNS lookup
nc -zv host 443 # test TCP port connectivity
Disk & Memory
df -h # disk usage by filesystem
du -sh * # size of files/dirs in current dir
free -h # memory usage
lsblk # list block devices
Permissions Cheat Sheet
| Octal | Permission |
|---|---|
| 7 | rwx |
| 6 | rw- |
| 5 | r-x |
| 4 | r-- |
| 0 | --- |
chmod 755 file → owner: rwx, group: r-x, others: r-x
Useful Shortcuts
| Shortcut | Action |
|---|---|
Ctrl + C |
Kill current command |
Ctrl + Z |
Suspend current command |
Ctrl + R |
Search command history |
!! |
Repeat last command |
Tab |
Auto-complete |
Archives
tar -czvf archive.tar.gz dir/ # create gzip archive
tar -xzvf archive.tar.gz # extract gzip archive