Linux_Cheat_Sheet
Linux_Cheat_Sheet
Basic Commands
pwd # Print current working directory
ls # List files in directory
ls -l # Long listing format
ls -a # Show hidden files
cd /path/to/dir # Change directory
cd .. # Go up one directory
cd - # Switch to previous directory
mkdir new_dir # Create a directory
rm file.txt # Remove file
rm -r dir_name # Remove directory and its contents
cp source dest # Copy file or directory
mv oldname newname # Rename or move file
clear # Clear terminal
Process Management
ps aux # List running processes
top # Show system resource usage
htop # Interactive process viewer
kill PID # Kill process by PID
killall process # Kill process by name
pkill name # Kill by partial name
bg # Resume a job in the background
fg # Resume a job in the foreground
jobs # Show background jobs
User Management
whoami # Show current user
who # Show logged-in users
id user # Show user ID (UID) and group ID (GID)
adduser username # Add new user
passwd username # Change user password
deluser username # Remove user
usermod -aG groupname username # Add user to group
Networking
ip a # Show IP addresses
ifconfig # Show network interfaces (deprecated, use `ip a`)
ping google.com # Test network connectivity
netstat -tulnp # Show open ports
ss -tulnp # Alternative to netstat
wget URL # Download file from URL
curl -O URL # Download file using curl
Disk Usage
df -h # Show disk usage in human-readable format
du -sh /path # Show folder size
lsblk # Show block devices
mount /dev/sdX /mnt # Mount a disk
umount /mnt # Unmount a disk
Package Management
Debian-based (Ubuntu, Debian)
apt update # Update package list
apt upgrade # Upgrade all packages
apt install pkg # Install package
apt remove pkg # Remove package
dpkg -i package.deb # Install .deb package
System Monitoring
uptime # Show system uptime
free -h # Show memory usage
df -h # Show disk usage
du -sh /dir # Show folder size
iostat # Show CPU usage (requires sysstat package)
vmstat # Show system performance