Linux Basic Commands Cheat Sheet
File & Directory Navigation
• pwd – Print working directory (shows current location)
• ls – List files and directories
• ls -l – List in long format
• ls -a – List including hidden files
• cd – Change directory
• cd .. – Go one level up
• cd ~ – Go to home directory
File & Directory Management
• mkdir – Create a new directory
• rmdir – Remove an empty directory
• rm -r – Remove directory and contents
• touch – Create an empty file
• cp file1 file2 – Copy file1 to file2
• mv file1 file2 – Move or rename file
• cat – Display file content
• nano / vi – Open file in text editor
Viewing & Searching
• more – View file page by page
• less – View file with navigation
• head -n 10 – Show first 10 lines
• tail -n 10 – Show last 10 lines
• grep 'word' file – Search for 'word' inside file
Permissions
• ls -l – Show file permissions
• chmod 755 – Change permissions
• chown user:group – Change file owner
System Information
• whoami – Show current user
• date – Show current date & time
• uptime – Show how long system is running
• uname -a – Show system details
• df -h – Show disk usage
• du -sh – Show size of a directory
• free -h – Show memory usage
Process Management
• ps – Show running processes
• top / htop – Monitor processes live
• kill – Kill a process by ID
• kill -9 – Force kill a process
Networking
• ping – Test connectivity
• ifconfig / ip a – Show network configuration
• curl – Fetch content from a URL
• wget – Download a file
Archiving & Compression
• tar -czf archive.tar.gz files/ – Create compressed archive
• tar -xzf archive.tar.gz – Extract archive
• zip file.zip file1 file2 – Create zip file
• unzip file.zip – Extract zip file
User Management
• who – Show logged-in users
• id – Show user ID and groups
• adduser – Add new user
• passwd – Change password
Package Management (Debian/Ubuntu)
• sudo apt update – Update package list
• sudo apt upgrade – Upgrade all packages
• sudo apt install – Install a package
• sudo apt remove – Remove a package