Linux Terminal Cheatsheet
Essential Linux commands for file operations, permissions, processes, and system administration.
| Command | Description | Syntax | Example | Category |
|---|---|---|---|---|
| pwd | Print working directory | pwd | pwd | Navigation |
| cd | Change directory | cd [path] | cd /home/user/projects | Navigation |
| ls | List directory contents | ls [options] | ls -la /home | Navigation |
| mkdir | Create directory | mkdir [options] path | mkdir -p /path/to/dir | Files |
| cp | Copy files/directories | cp [options] source dest | cp -r src/ dest/ | Files |
| mv | Move/rename files | mv source dest | mv file.txt /home/user/ | Files |
| rm | Remove files/directories Careful: rm -rf deletes everything under the path at once: no confirmation, no recycle bin. Check the path before pressing Enter (a stray space, as in rm -rf / tmp, starts from /). Use rm -ri to be asked for each file when unsure. | rm [options] path | rm -rf /path/to/dir | Files |
| touch | Create empty file | touch filename | touch new_file.txt | Files |
| cat | View file contents | cat filename | cat /etc/hostname | Files |
| less | View file with pagination | less filename | less /var/log/syslog | Files |
| head | View first lines of file | head -n count filename | head -n 20 file.txt | Files |
| tail | View last lines of file | tail -n count filename | tail -f /var/log/app.log | Files |
| chmod | Change file permissions Careful: Avoid chmod 777: it lets every user change or replace the file. Usual values are 755 for scripts and folders and 644 for ordinary files. Be wary of chmod -R on system folders, which is hard to undo. | chmod mode file | chmod 755 script.sh | Permissions |
| chown | Change file owner | chown user:group file | chown user:group /home/user/file | Permissions |
| sudo | Execute with super user privileges Careful: sudo runs the command as root, so permission checks no longer protect you. Only use it for commands you understand, and never pipe a downloaded script straight into sudo bash. | sudo command | sudo apt-get install package | Permissions |
| ps | List running processes | ps [options] | ps aux | Processes |
| kill | Terminate process Careful: kill -9 (SIGKILL) stops the process instantly, with no chance to save work or clean up, which can corrupt files or leave locks behind. Try plain kill 1234 (SIGTERM) first and use -9 only if it does not stop. | kill -signal pid | kill -9 1234 | Processes |
| top | Monitor system processes | top | top | Processes |
| find | Search for files | find path -name pattern | find /home -name "*.js" | Search |
| grep | Search file contents | grep [options] pattern file | grep -r "function" src/ | Search |
| df | Show disk space usage | df [options] | df -h | System |
| du | Show directory size | du [options] path | du -sh /home/user | System |
| whoami | Show current user | whoami | whoami | System |
| uname | Show system information | uname [options] | uname -a | System |
| tar (create) | Pack a folder into a gzip-compressed archive | tar -czf archive.tar.gz folder/ | tar -czf backup-2026-11.tar.gz ~/projects | Archives |
| tar (extract) | Unpack a .tar.gz archive, optionally into another folder | tar -xzf archive.tar.gz [-C dir] | tar -xzf backup-2026-11.tar.gz -C /tmp/restore | Archives |
| tar (list) | List what is inside an archive without unpacking it | tar -tzf archive.tar.gz | tar -tzf backup-2026-11.tar.gz | head | Archives |
| gzip / gunzip | Compress or decompress a single file (replaces the original) | gzip file | gunzip file.gz | gzip -k access.log # -k keeps the original | Archives |
| zip / unzip | Create or extract .zip files (handy for sharing with Windows users) | zip -r out.zip dir/ | unzip out.zip -d dir/ | zip -r site.zip public/ && unzip site.zip -d /tmp/site | Archives |
| ip | Show network interfaces and IP addresses | ip addr | ip route | ip -brief addr | Networking |
| ping | Check whether a host is reachable and how long replies take | ping -c count host | ping -c 4 bharatscholar.com | Networking |
| curl | Make an HTTP request: fetch a page, an API or just its headers | curl [options] URL | curl -I https://bharatscholar.com # headers only | Networking |
| wget | Download a file from a URL | wget [options] URL | wget -c https://example.com/big.iso # -c resumes | Networking |
| ss | List open sockets: which ports are listening and which program owns them | ss [options] | ss -tulpn | Networking |
| dig | Look up DNS records for a domain | dig domain [type] | dig bharatscholar.com MX +short | Networking |
| traceroute | Show each network hop on the way to a host | traceroute host | traceroute google.com | Networking |
| ssh | Log in to a remote machine securely | ssh [-p port] user@host | ssh -p 2222 deploy@203.0.113.10 | SSH & remote |
| ssh-keygen | Create an SSH key pair (use instead of passwords) | ssh-keygen -t ed25519 -C "comment" | ssh-keygen -t ed25519 -C "laptop" | SSH & remote |
| ssh-copy-id | Install your public key on a server so you can log in without a password | ssh-copy-id user@host | ssh-copy-id deploy@203.0.113.10 | SSH & remote |
| scp | Copy files to or from a remote machine over SSH | scp source user@host:path | scp report.pdf deploy@203.0.113.10:/srv/files/ | SSH & remote |
| rsync | Sync folders locally or over SSH, copying only what changed Careful: With --delete, rsync removes files in the destination that are not in the source. Run it once with -n (dry run) first. | rsync -avz source/ dest/ | rsync -avz --delete site/ deploy@203.0.113.10:/var/www/site/ | SSH & remote |