Linux Commands Cheat Sheet

Common Linux commands: file/dir, process, network, permission and monitoring commands with notes, for quick lookup while working.

CommandDescription
lsList directory contents (-l long, -a include hidden)
cdChange directory (cd ~ home)
pwdPrint working directory (absolute path)
cpCopy file/dir (-r recursive)
mvMove or rename
rmRemove (-r recursive, -f force)
mkdirMake directory (-p recursive)
rmdirRemove empty directory
catPrint entire file
lessPaginated view (scroll up/down)
headShow first lines (-n count)
tailShow last lines (-f follow)
grepText search (-r recursive, -i ignore case)
findFind files by criteria
chmodChange file permissions (rwx)
chownChange file owner/group
psList processes (aux full format)
topReal-time process/resource monitor
killTerminate process (kill -9 force)
dfDisk space usage (-h human)
duDirectory/file size (-sh summary)
freeMemory usage (-h human)
unameKernel info (-a all)
uptimeUptime and load average
tarArchive/extract (-czf compress, -xzf extract)
sshSecure remote login
scpSecure remote copy
rsyncIncremental file sync
curlSend HTTP request / download
wgetCommand-line download
ssShow network connections (-tlnp)
pingTest network connectivity
ipShow/configure network interfaces
systemctlManage system services
crontabManage scheduled jobs (-e edit)
historyShow command history

Frequently Asked Questions

How do I recursively find a file type?

Use `find . -name "*.log"` to search the current dir and subdirs; add -type f for files only, -mtime -1 for files changed within a day.

How do I watch a log file in real time?

Use `tail -f app.log` to stream new lines; pipe to grep to filter: `tail -f app.log | grep ERROR`.

How do I make a script executable?

Use `chmod +x script.sh` to grant owner execute; for others too use `chmod 755 script.sh`.

How do I keep a process running in the background?

Use `nohup cmd &` to survive hangup, or register a systemd service managed by `systemctl` that auto-restarts on reboot.