Linux Cheatsheet
Linux Cheatsheet
Linux Cheatsheet
developer
Basic Commands
1. Navigation
pwd - Print working directory
ls - List directory contents
cd [directory] - Change directory
cd .. - Move to parent directory
2. File Operations
touch [file] - Create a new file
cat [file] - Display file content
cp [source] [destination] - Copy files or directories
mv [source] [destination] - Move or rename files or directories
rm [file] - Remove a file
rm -r [directory] - Remove a directory and its contents
3. Directory Operations
mkdir [directory] - Create a new directory
rmdir [directory] - Remove an empty directory
Intermediate Commands
1. Permissions
chmod [permissions] [file] - Change file permissions
chown [owner]:[group] [file] - Change file owner and group
4. System Monitoring
top - Display tasks and system resource usage
htop - Interactive process viewer
ps aux - Show all running processes
df -h - Display disk space usage in human-readable format
du -h [directory] - Display directory size in human-readable format
Advanced Commands
1. Package Management (Debian-based)
apt-get update - Update package list
apt-get upgrade - Upgrade installed packages
apt-get install [package] - Install a package
apt-get remove [package] - Remove a package
3. User Management
adduser [username] - Add a new user
passwd [username] - Change a user's password
usermod -aG [group] [username] - Add a user to a group
deluser [username] - Delete a user
4. Disk Management
fdisk -l - List disk partitions
mkfs.ext4 [device] - Create an ext4 filesystem
mount [device] [directory] - Mount a filesystem
umount [directory] - Unmount a filesystem
5. System Control
systemctl status [service] - Check the status of a service
systemctl start [service] - Start a service
systemctl stop [service] - Stop a service
systemctl restart [service] - Restart a service
systemctl enable [service] - Enable a service to start at boot
systemctl disable [service] - Disable a service from starting at boot
6. Advanced Networking
ip a - Show network interfaces and IP addresses
iptables -L - List firewall rules
ssh [user]@[host] - Connect to a remote host via SSH
scp [file] [user]@[host]:[destination] - Secure copy files between hosts
7. Process Management
kill [PID] - Terminate a process by PID
killall [process_name] - Terminate all processes with a given name
nohup [command] & - Run a command immune to hangups, with output to a non-
tty
3. Scheduled Tasks
crontab -e - Edit user crontab
crontab -l - List user crontab entries
at [time] - Schedule a command to be run at a specified time
4. System Information
uname -a - Print all system information
hostnamectl - Query and change the system hostname
dmesg - Print or control the kernel ring buffer
lshw - List hardware configuration
5. Text Processing
awk '{print $1}' [file] - Extract the first column of a file
sed 's/old/new/g' [file] - Replace all occurrences of 'old' with 'new' in a
file
cut -d ' ' -f1 [file] - Cut out the first field of a file
6. Advanced Networking
traceroute [host] - Print the route packets take to the network host
nc -zv [host] [port] - Check the open port on a remote host
ss -tuln - List open sockets
8. Security
gpg -c [file] - Encrypt a file
gpg [file.gpg] - Decrypt a file
ssh-keygen -t rsa - Generate an RSA key pair
chmod 700 [directory] - Set directory permissions to be accessible only by
the owner