Tutorial 📅 January 2025 📖 8 min read

Debian Commands Cheat Sheet: 150+ Essential Commands (2025)

Complete Debian commands cheat sheet with 150+ essential commands. Package management, system admin, networking, file operations. Copy-paste ready for Debian 11, 12.

Complete Debian Linux commands cheat sheet for system administrators and developers. All essential Debian commands organized by category with copy-paste ready examples. Works with Debian 11 (Bullseye), Debian 12 (Bookworm), and newer versions.

Quick Navigation:
📦 Package Management (APT) | 📁 File Operations | 👤 User Management
🌐 Networking | 🔥 Firewall | 💾 Disk Management | 📊 System Monitoring
🔒 Permissions | 🔄 Process Management | 📋 Service Management

📦 Package Management (APT)

Update & Upgrade

# Update package lists
apt update

# Upgrade all packages
apt upgrade

# Full upgrade (handles dependencies)
apt full-upgrade

# Dist upgrade
apt dist-upgrade

Install & Remove Packages

# Install package
apt install package-name

# Install multiple packages
apt install package1 package2 package3

# Install specific version
apt install package-name=version

# Remove package (keep config files)
apt remove package-name

# Remove package and config files
apt purge package-name

# Remove unused dependencies
apt autoremove

# Remove unused packages and config
apt autoremove --purge

Search & Information

# Search for package
apt search keyword

# Show package information
apt show package-name

# List installed packages
apt list --installed

# List upgradable packages
apt list --upgradable

# Show package dependencies
apt depends package-name

# Show reverse dependencies
apt rdepends package-name

Cache & Cleanup

# Clean package cache
apt clean

# Remove old package files
apt autoclean

# Check for broken dependencies
apt check

# Fix broken dependencies
apt --fix-broken install
Pro Tip:
Use apt instead of apt-get for interactive use. apt combines apt-get and apt-cache with better output formatting.

📁 File & Directory Operations

Navigation & Listing

# List files
ls
ls -la              # Detailed list with hidden files
ls -lh              # Human-readable file sizes
ls -ltr             # Sort by time, oldest first

# Change directory
cd /path/to/dir
cd ..               # Parent directory
cd ~                # Home directory
cd -                # Previous directory

# Print working directory
pwd

# Show directory tree
tree
tree -L 2           # Limit depth to 2 levels

Create, Copy, Move

# Create directory
mkdir dirname
mkdir -p path/to/nested/dir

# Create file
touch filename

# Copy files
cp source dest
cp -r source/ dest/     # Recursive (directories)
cp -a source/ dest/     # Archive mode (preserve all)

# Move/Rename
mv source dest
mv oldname newname

# Remove files/directories
rm filename
rm -r dirname           # Recursive
rm -rf dirname          # Force recursive (dangerous!)

View & Edit Files

# View file content
cat filename
less filename           # Paginated view
head filename           # First 10 lines
head -n 20 filename     # First 20 lines
tail filename           # Last 10 lines
tail -f filename        # Follow file (live updates)

# Edit files
nano filename
vi filename
vim filename

Search & Find

# Find files by name
find /path -name "*.txt"
find . -type f -name "file*"
find . -type d -name "dirname"

# Find files by size
find . -size +100M      # Larger than 100MB
find . -size -1M        # Smaller than 1MB

# Find and execute
find . -name "*.log" -exec rm {} \;

# Search in files (grep)
grep "pattern" filename
grep -r "pattern" /path     # Recursive
grep -i "pattern" file      # Case insensitive
grep -n "pattern" file      # Show line numbers

👤 User & Group Management

User Operations

# Add user
adduser username
useradd username

# Delete user
deluser username
userdel username
userdel -r username     # Remove home directory too

# Change password
passwd username
passwd                  # Change own password

# Modify user
usermod -aG groupname username  # Add to group
usermod -l newname oldname      # Rename user
usermod -s /bin/bash username   # Change shell

# Switch user
su username
su -                    # Switch to root
sudo command            # Run command as root

Group Operations

# Add group
addgroup groupname
groupadd groupname

# Delete group
delgroup groupname
groupdel groupname

# Show user groups
groups username
id username

🔒 Permissions & Ownership

# Change permissions (numeric)
chmod 644 file          # rw-r--r--
chmod 755 file          # rwxr-xr-x
chmod 600 file          # rw-------
chmod -R 755 dir        # Recursive

# Change permissions (symbolic)
chmod u+x file          # Add execute for user
chmod g-w file          # Remove write for group
chmod o=r file          # Set read-only for others
chmod a+r file          # Add read for all

# Change ownership
chown user:group file
chown -R user:group dir # Recursive
chown user file         # Change user only
chgrp group file        # Change group only

# View permissions
ls -l filename
stat filename
Warning:
Never run chmod 777 or chmod -R 777 on production systems! This gives full permissions to everyone and is a major security risk.

🌐 Networking Commands

Network Configuration

# Show network interfaces
ip addr show
ip a
ifconfig                # Legacy command

# Show routing table
ip route show
route -n

# Show network statistics
netstat -tulpn
ss -tulpn               # Modern alternative

# Test connectivity
ping example.com
ping -c 4 example.com   # Send 4 packets

# Trace route
traceroute example.com
mtr example.com         # Interactive traceroute

# DNS lookup
nslookup example.com
dig example.com
host example.com

Download & Transfer

# Download files
wget https://example.com/file.zip
wget -c url             # Continue interrupted download
curl -O https://example.com/file.zip
curl -L url             # Follow redirects

# Transfer files (SCP)
scp file.txt user@host:/path/
scp user@host:/path/file.txt .
scp -r dir/ user@host:/path/

# Rsync (sync files)
rsync -avz source/ dest/
rsync -avz source/ user@host:/path/

🔥 Firewall (UFW & iptables)

UFW (Uncomplicated Firewall)

# Enable/Disable UFW
ufw enable
ufw disable

# Check status
ufw status
ufw status verbose

# Allow/Deny ports
ufw allow 22            # Allow SSH
ufw allow 80/tcp        # Allow HTTP
ufw allow 443/tcp       # Allow HTTPS
ufw deny 3306           # Deny MySQL

# Allow from specific IP
ufw allow from 192.168.1.100

# Delete rule
ufw delete allow 80

# Reset firewall
ufw reset

iptables (Advanced)

# List rules
iptables -L
iptables -L -v -n

# Allow port
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

# Block IP
iptables -A INPUT -s 192.168.1.100 -j DROP

# Save rules
iptables-save > /etc/iptables/rules.v4

# Restore rules
iptables-restore < /etc/iptables/rules.v4

💾 Disk & Storage Management

Disk Usage

# Show disk space
df -h                   # Human-readable
df -i                   # Inode usage

# Show directory sizes
du -h /path
du -sh /path            # Summary only
du -h --max-depth=1     # One level deep

# Show largest directories
du -h / | sort -rh | head -20

# Check disk usage by file type
find . -name "*.log" -exec du -ch {} + | tail -1

Mount & Unmount

# Show mounted filesystems
mount
df -h

# Mount filesystem
mount /dev/sda1 /mnt
mount -t ext4 /dev/sda1 /mnt

# Unmount
umount /mnt
umount /dev/sda1

# Mount all in fstab
mount -a

# Check fstab
cat /etc/fstab

Disk Partitioning

# List disks
lsblk
fdisk -l

# Partition disk (interactive)
fdisk /dev/sda

# Format partition
mkfs.ext4 /dev/sda1
mkfs.xfs /dev/sda1

# Check filesystem
fsck /dev/sda1
e2fsck /dev/sda1

🔄 Process Management

# List processes
ps aux
ps -ef
top                     # Interactive
htop                    # Better interactive (install first)

# Find process
ps aux | grep processname
pgrep processname

# Kill process
kill PID
kill -9 PID             # Force kill
killall processname
pkill processname

# Process priority
nice -n 10 command      # Start with priority
renice -n 5 -p PID      # Change priority

# Background processes
command &               # Run in background
jobs                    # List background jobs
fg %1                   # Bring job 1 to foreground
bg %1                   # Resume job 1 in background

📋 Service Management (systemd)

# Start/Stop services
systemctl start servicename
systemctl stop servicename
systemctl restart servicename
systemctl reload servicename

# Enable/Disable services
systemctl enable servicename
systemctl disable servicename

# Check service status
systemctl status servicename
systemctl is-active servicename
systemctl is-enabled servicename

# List all services
systemctl list-units --type=service
systemctl list-units --type=service --state=running

# View logs
journalctl -u servicename
journalctl -u servicename -f       # Follow logs
journalctl -u servicename --since today

📊 System Monitoring

System Information

# System info
uname -a                # Kernel info
hostnamectl             # Hostname and OS info
lsb_release -a          # Debian version
cat /etc/debian_version # Debian version

# Hardware info
lscpu                   # CPU info
lsmem                   # Memory info
lspci                   # PCI devices
lsusb                   # USB devices
lsblk                   # Block devices

Resource Monitoring

# CPU & Memory
top
htop
free -h                 # Memory usage
vmstat 1                # Virtual memory stats

# Disk I/O
iostat
iotop

# Network traffic
iftop
nethogs

# Load average
uptime
w

🔍 Log Files

# System logs
tail -f /var/log/syslog
tail -f /var/log/messages
journalctl -f

# Authentication logs
tail -f /var/log/auth.log

# Application logs
tail -f /var/log/apache2/error.log
tail -f /var/log/nginx/error.log
tail -f /var/log/mysql/error.log

# Search logs
grep "error" /var/log/syslog
journalctl -p err       # Show errors only

⚡ Quick Commands Reference

System Control

# Reboot system
reboot
systemctl reboot

# Shutdown
shutdown now
shutdown -h now
poweroff

# Schedule shutdown
shutdown -h +10         # Shutdown in 10 minutes
shutdown -r 22:00       # Reboot at 10 PM

Archive & Compression

# Tar archives
tar -czf archive.tar.gz /path       # Create gzip archive
tar -xzf archive.tar.gz              # Extract gzip archive
tar -cjf archive.tar.bz2 /path      # Create bzip2 archive
tar -xjf archive.tar.bz2            # Extract bzip2 archive

# Zip
zip -r archive.zip /path
unzip archive.zip

# View archive contents
tar -tzf archive.tar.gz

Text Processing

# Cut, sort, unique
cut -d':' -f1 /etc/passwd
sort filename
sort -r filename        # Reverse
uniq filename           # Remove duplicates
sort filename | uniq

# Word count
wc filename
wc -l filename          # Line count
wc -w filename          # Word count

# Sed (stream editor)
sed 's/old/new/' file
sed 's/old/new/g' file  # Global replace

# Awk
awk '{print $1}' file   # Print first column
awk -F':' '{print $1}' /etc/passwd
Prefer GUIs over terminal?
VPS Commander provides a visual interface for all these operations. No command line knowledge required!
Try VPS Commander Free

Conclusion

This Debian commands cheat sheet covers the most essential commands for managing Debian Linux systems. Bookmark this page for quick reference when working with Debian 11, Debian 12, or newer versions.

Tired of memorizing commands?
VPS Commander provides a visual interface for Debian server management. No terminal commands needed.
Try it free: $2.99/month or $25/year

→ Get VPS Commander Now

Related Articles