Linux Commands Cheat Sheet
File and Directory Management
`ls` → list files and directories
`ls -a` → list all files (including hidden ones)
`ls -l` → detailed file info
`mkdir ` → create directory
`cd ` → change directory
`cd` / `cd ~` → go to home directory
`cd ..` → move up one directory
`pwd` → print current directory path
Copying, Moving, Deleting
`cp file1 file2` → copy file1 to file2
`cp -R dir1 dir2` → copy directories recursively
`mv file1 dir/` → move file1 into dir
`mv file1 file2` → rename file1
`rm file` → delete file
`rmdir dir` → remove empty directory
`rm -r dir` → delete directory and contents
Viewing File Contents
`clear` → clear terminal
`cat file` → display file
`less file` → view file page by page
`head file` → first 10 lines
`tail file` → last 10 lines
Searching & Counting
`grep 'pattern' file` → search in file
`grep -i pattern file` → case-insensitive search
`grep -v pattern file` → exclude matches
`wc -l file` → count lines
`wc -w file` → count words
`wc -m file` → count characters
Redirection & Pipes
`command > file` → redirect output
`command >> file` → append output
`command 2> file` → redirect error
`command < file` → input from file
`cmd1 | cmd2` → pipe output
Help & Wildcards
`man command` → manual page
`whatis command` → short description
`apropos keyword` → search by keyword
`*` → match any characters
`?` → match one character
Permissions & Processes
`ls -l` → show permissions
`chmod [opts] file` → change permissions
`ps` → show processes
`command &` → run in background
`jobs` → list jobs
`fg %n` → foreground job
`bg %n` → background job
`kill %n` → kill job
`kill PID` → kill process by ID
Disk Usage & File Utilities
`quota` / `quotacheck` → check quota
`df -h` → disk usage
`du -sh *` → directory sizes
`gzip file` → compress file
`gunzip file.gz` → uncompress file
`file filename` → detect file type
`history` → show history
`find . -name 'pattern'` → find files
`locate file` → locate files
`wget URL` → download file
Variables & Environment
`echo $VAR` → show variable
`env` → list environment vars
`VAR=value` → set variable
`export VAR=value` → export var
`source ~/.bashrc` → reload config
`which command` → path to command
Compiling & Software Management
`./configure` → configure source
`make` → compile
`make check` → run tests
`make install` → install
`make clean` → cleanup
`tar -xvf file.tar` → extract tar file
`tar -zxvf file.tar.gz` → extract tar.gz
`strip file` → strip debug info
Shell Scripting
`#!/bin/bash` → script header
`chmod +x script.sh` → make executable
`./script.sh` → run script
`for ... do ... done` → loop
`if [ condition ]; then ... fi` → conditional