Linux Commands Cheat Sheet
- Basic File and Directory Commands
ls - List directory contents
cd [dir] - Change directory
pwd - Show current directory
mkdir [dir] - Create new directory
rmdir [dir] - Remove empty directory
rm [file] - Delete file
rm -r [dir] - Delete directory recursively
cp [src] [dest] - Copy files/directories
mv [src] [dest] - Move or rename file/directory
touch [file] - Create empty file
- File Viewing and Editing
cat [file] - View file content
less [file] - Scrollable file viewer
more [file] - Basic file viewer
head [file] - Show first 10 lines
tail [file] - Show last 10 lines
nano [file] - Edit file using Nano
vi [file] - Edit file using Vi/Vim
- Searching and Finding
find [dir] -name [file] - Search for a file
grep '[text]' [file] - Search text in file
locate [file] - Locate file in system
- File Permissions and Ownership
chmod [mode] [file] - Change file permissions
chown [user] [file] - Change file owner
chgrp [group] [file] - Change file group
- System Info and Monitoring
top - Real-time process monitor
ps aux - Show running processes
df -h - Show disk space
du -sh [dir] - Disk usage of a directory
free -h - Show memory usage
uptime - Show system uptime
uname -a - System information
- User Management
whoami - Show current user
who - Show logged-in users
id - Show user ID/group
passwd - Change user password
adduser [user] - Add user
su [user] - Switch user
sudo [command] - Run command as root
- Networking
ping [host] - Test network connection
ifconfig - Show IP address and interfaces
ip a - Modern alternative to ifconfig
netstat -tuln - Show open ports
ssh user@host - Connect via SSH
scp [file] user@host:[path] - Copy file over SSH
- Package Management (Debian/Ubuntu)
apt update - Update package index
apt upgrade - Upgrade packages
apt install [pkg] - Install package
apt remove [pkg] - Remove package
- Archiving and Compression
tar -czvf file.tar.gz [dir] - Create archive
tar -xzvf file.tar.gz - Extract archive
unzip file.zip - Extract ZIP file