Here's a Linux Command Cheat Sheet for quick reference! ๐
๐น File & Directory Management
Command | Description |
ls | List files in a directory |
ls -l | List files in long format |
ls -a | Show hidden files |
pwd | Print current working directory |
cd <dir> | Change directory |
cd .. | Move up one directory |
mkdir <dir> | Create a new directory |
rmdir <dir> | Remove an empty directory |
rm <file> | Delete a file |
rm -r <dir> | Remove a directory and its contents |
cp <source> <dest> | Copy a file |
mv <source> <dest> | Move or rename a file |
touch <file> | Create a new empty file |
find <dir> -name <filename> | Search for a file |
tree | Display directory structure |
๐น File Permissions
Command | Description |
chmod 755 <file> | Change file permissions (owner: rwx, group: r-x, others: r-x) |
chown user:group <file> | Change file owner and group |
ls -l | View file permissions |
umask 022 | Default permissions for new files |
๐น File Content & Editing
Command | Description |
cat <file> | View file contents |
tac <file> | View file in reverse |
less <file> | View file one page at a time |
head -n <num> <file> | View first N lines of a file |
tail -n <num> <file> | View last N lines of a file |
nano <file> | Open file in Nano editor |
vim <file> | Open file in Vim editor |
echo "text" > <file> | Write text to a file (overwrite) |
echo "text" >> <file> | Append text to a file |
grep "text" <file> | Search for text in a file |
wc -l <file> | Count number of lines in a file |
diff <file1> <file2> | Compare two files |
sort <file> | Sort lines in a file |
๐น User Management
Command | Description |
whoami | Show current user |
who | Show logged-in users |
id | Show user ID and group ID |
adduser <user> | Add a new user |
passwd <user> | Change user password |
deluser <user> | Delete a user |
groupadd <group> | Create a new group |
usermod -aG <group> <user> | Add user to a group |
๐น Process Management
Command | Description |
ps aux | Show all running processes |
top | Display active processes in real-time |
htop | Interactive process viewer (if installed) |
kill <PID> | Kill a process by PID |
killall <process> | Kill all processes by name |
pkill <process> | Kill process by name |
nohup <command> & | Run command in background (ignore hangups) |
๐น Networking
Command | Description |
ping <host> | Check connectivity to a host |
curl <URL> | Fetch content from a URL |
wget <URL> | Download a file from a URL |
ifconfig | Show network interfaces (deprecated) |
ip addr show | Show network interfaces (modern alternative) |
netstat -tulnp | List open ports |
ss -tulnp | Alternative to netstat for open ports |
scp <file> user@host:/path | Copy files over SSH |
rsync -avz <source> <dest> | Sync files/directories |
hostname -I | Show local IP address |
๐น Disk & Storage
Command | Description |
df -h | Show disk space usage |
du -sh <dir> | Show size of a directory |
lsblk | Show block devices (partitions) |
mount /dev/sdX /mnt | Mount a disk partition |
umount /mnt | Unmount a partition |
fdisk -l | Show partition table |
๐น System Monitoring
Command | Description |
uptime | Show system uptime |
free -h | Show memory usage |
vmstat | Show system performance |
iostat | Show CPU & disk stats |
dmesg | Show boot log messages |
๐น Package Management
๐น Debian/Ubuntu (apt
)
Command | Description |
sudo apt update | Update package list |
sudo apt upgrade | Upgrade installed packages |
sudo apt install <package> | Install a package |
sudo apt remove <package> | Remove a package |
dpkg -l | List installed packages |
๐น Red Hat/CentOS (yum
or dnf
)
Command | Description |
sudo yum install <package> | Install a package |
sudo yum remove <package> | Remove a package |
sudo yum update | Update system |
๐น Arch (pacman
)
Command | Description |
sudo pacman -S <package> | Install a package |
sudo pacman -R <package> | Remove a package |
๐น Compression & Archiving
Command | Description |
tar -cvf archive.tar <files> | Create a tar archive |
tar -xvf archive.tar | Extract a tar archive |
tar -czvf archive.tar.gz <files> | Create a gzip-compressed tar archive |
tar -xzvf archive.tar.gz | Extract a gzip-compressed tar archive |
zip archive.zip <files> | Create a zip archive |
unzip archive.zip | Extract a zip file |
๐น Permissions & Ownership
Command | Description |
chmod 755 <file> | Change file permissions (rwx for owner, rx for others) |
chmod +x <file> | Make file executable |
chown user:group <file> | Change file owner/group |
sudo | Execute command as root |
๐น Shortcuts & Misc
Command | Description |
clear | Clear terminal screen |
history | Show command history |
alias ll='ls -la' | Create a shortcut for a command |
unalias ll | Remove an alias |
!! | Repeat the last command |
CTRL + C | Stop a running process |
CTRL + Z | Suspend a process |
bg | Resume a suspended process in background |
fg | Resume a process in foreground |
๐ฅ Grab your free PDF here of this cheat sheet
Visit my website
Subscribe to my newsletter
Read articles from Rudraksh Laddha directly inside your inbox. Subscribe to the newsletter, and don't miss out.