Speed Up Your System

Optimize Debian for better performance and responsiveness

01

Use ZRAM for Swap Compression

Instead of a traditional swap partition, use ZRAM to compress data in memory. This dramatically improves performance on systems with limited RAM.

bash
$ sudo apt install zram-tools
$ sudo systemctl enable --now zramswap
$ zramctl  # Verify it's working
02

Enable TRIM for SSDs

Regularly running TRIM on SSDs maintains their performance over time. Set up a weekly fstrim timer:

bash
$ sudo systemctl enable --now fstrim.timer
$ systemctl status fstrim.timer
03

Use a Faster DNS

Replace your ISP's DNS with faster, more reliable options like Cloudflare (1.1.1.1) or Google (8.8.8.8):

bash
# Edit resolv.conf or use systemd-resolved
$ echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf
$ echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf

# Or install DNS-over-HTTPS with systemd-resolved
$ sudo systemd-resolve --set-dns 1.1.1.1 8.8.8.8
04

Reduce Swap Usage (Swappiness)

Lower the swappiness value to prefer RAM over swap, reducing disk I/O:

bash
# Check current value (default is 60)
$ cat /proc/sys/vm/swappiness

# Set to 10 (prefer RAM over swap)
$ echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-swappiness.conf
$ sudo sysctl --system
05

Use a Lightweight Desktop

If your system feels slow, switch to a lighter desktop environment:

bash
# Install XFCE (lightweight, feature-rich)
$ sudo apt install task-xfce-desktop

# Or LXQt (even lighter)
$ sudo apt install task-lxqt-desktop

# Or MATE (traditional, moderate weight)
$ sudo apt install task-mate-desktop
06

Clean Up Regularly

Set up automatic cleanup to keep your system running smoothly:

bash
# Create a cleanup script
$ cat >~/cleanup.sh <<'EOF'
#!/bin/bash
sudo apt clean
sudo apt autoremove --purge -y
sudo journalctl --vacuum-time=7d
rm -rf ~/.cache/thumbnails/*
echo "Cleanup complete!"
EOF
$ chmod +x ~/cleanup.sh

# Run weekly via cron
$ crontab -e
# Add: 0 3 * * 0 ~/cleanup.sh

Hardening Your System

Essential security measures every Debian user should implement

07

Configure a Firewall

Always run a firewall. UFW (Uncomplicated Firewall) is the easiest to configure:

bash
$ sudo apt install ufw
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow 22/tcp    # SSH
$ sudo ufw allow 80/tcp   # HTTP
$ sudo ufw allow 443/tcp  # HTTPS
$ sudo ufw enable
08

SSH Hardening

Secure your SSH server against brute-force attacks:

bash
# Edit SSH config
$ sudo nano /etc/ssh/sshd_config

# Recommended settings:
Port 2222                     # Non-standard port
PermitRootLogin no            # Disable root login
PasswordAuthentication no     # Use keys only
MaxAuthTries 3                # Limit login attempts
ClientAliveInterval 300       # Timeout idle sessions

$ sudo systemctl restart ssh

# Install fail2ban for brute-force protection
$ sudo apt install fail2ban
09

Enable Automatic Security Updates

Keep your system patched automatically:

bash
$ sudo apt install unattended-upgrades
$ sudo dpkg-reconfigure unattended-upgrades

# Configure in /etc/apt/apt.conf.d/50unattended-upgrades
# Enable automatic reboot if needed
$ echo "Unattended-Upgrade::Automatic-Reboot \"true\";" | sudo tee /etc/apt/apt.conf.d/auto-reboot
10

Full Disk Encryption

If you didn't encrypt during installation, you can still protect sensitive data:

bash
# Encrypt a specific partition/drive
$ sudo cryptsetup luksFormat /dev/sdX1
$ sudo cryptsetup luksOpen /dev/sdX1 encrypted
$ sudo mkfs.ext4 /dev/mapper/encrypted
$ sudo mount /dev/mapper/encrypted /mnt/secure

Power User Tips

Advanced tricks to boost your productivity and customize your Debian experience

11

Customize Your Shell (Bash/Zsh)

Enhance your terminal experience with aliases, functions, and Oh My Zsh:

bash
# Useful aliases for ~/.bashrc
alias update='sudo apt update && sudo apt full-upgrade -y'
alias clean='sudo apt autoremove --purge -y && sudo apt autoclean'
alias ll='ls -la --color=auto'
alias ..='cd ..'
alias ....='cd ../..'

# Install Oh My Zsh for a better shell
$ sudo apt install zsh
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# Install powerlevel10k theme
$ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
12

Use tmux for Terminal Multiplexing

tmux lets you run multiple terminal sessions in one window and detach/reattach:

bash
$ sudo apt install tmux

# Basic tmux commands (prefix is Ctrl+b)
# Ctrl+b %  → Split vertically
# Ctrl+b "  → Split horizontally
# Ctrl+b ←→ → Navigate between panes
# Ctrl+b c  → Create new window
# Ctrl+b d  → Detach from session
$ tmux new -s myproject   # Named session
$ tmux attach -t myproject # Reattach
13

Set Up Snapshots with Timeshift

Create system snapshots for easy rollback in case something breaks:

bash
$ sudo apt install timeshift

# Create a snapshot
$ sudo timeshift --create --comments "Before upgrade"

# List snapshots
$ sudo timeshift --list

# Restore a snapshot (use with caution!)
$ sudo timeshift --restore --snapshot "2024-01-15_12-00-00"
14

Use debsums to Verify Package Integrity

Check if any system files have been modified or tampered with:

bash
$ sudo apt install debsums

# Check all packages
$ sudo debsums -c

# Check specific package
$ sudo debsums nginx

# Check after a security update
$ sudo debsums --all --changed
15

Pin APT Repositories

Control which version of a package gets installed by pinning specific repositories:

bash
# Create a pin preference file
$ cat | sudo tee /etc/apt/preferences.d/vim-pin <<'EOF'
Package: vim
Pin: release a=stable
Pin-Priority: 900
EOF

# Check pin status
$ apt-cache policy vim

# Pin a specific version
$ sudo apt install vim=2:8.2.3995-1
16

Use Alias for Sudo Commands

Save time with smart aliases that combine common operations:

bash
# Add to ~/.bashrc
alias supdate='sudo apt update && sudo apt list --upgradable'
alias supgrade='sudo apt update && sudo apt full-upgrade -y'
alias sclean='sudo apt autoremove --purge -y && sudo apt clean'
alias sgrep='sudo grep -r --include="*.conf"'
alias sysinfo='neofetch || screenfetch'

# Install neofetch for system info
$ sudo apt install neofetch
17

Manage Services with Systemctl Aliases

Create quick functions to manage common services without typing full commands:

bash
# Add to ~/.bashrc
svc() {
    sudo systemctl "$@"
}

# Usage examples:
$ svc status nginx
$ svc restart ssh
$ svc enable --now fail2ban
$ svc list-units --failed
18

Use ripgrep for Fast Searching

ripgrep is a blazingly fast alternative to grep for searching through files:

bash
$ sudo apt install ripgrep

# Search for a pattern in all files
$ rg "error" /var/log/

# Search only in specific file types
$ rg "TODO" -t py src/

# Search with context lines
$ rg "config" -C 3 /etc/nginx/

# Count matches
$ rg -c "warning" /var/log/syslog

Backup & Recovery

Protect your data with reliable backup strategies and monitoring tools

19

Monitor Disk Space with ncdu

ncdu is an interactive disk usage analyzer that helps you find large files quickly:

bash
$ sudo apt install ncdu

# Analyze a directory
$ ncdu /home

# Analyze entire system (as root)
$ sudo ncdu /

# Exclude certain directories
$ ncdu -x /  # Stay on same filesystem

# Quick one-liner check
$ df -h /
20

Set Up Encrypted Backups with Restic

Restic provides deduplicated, encrypted backups to any storage backend:

bash
$ sudo apt install restic

# Initialize a backup repository
$ export RESTIC_REPOSITORY=/mnt/backup/debian
$ export RESTIC_PASSWORD="your-strong-password"
$ restic init

# Backup your home directory
$ restic backup /home --tag home

# List backups
$ restic snapshots

# Restore a specific snapshot
$ restic restore latest --target /mnt/restore
21

Check Disk Health with smartctl

Monitor your drive's health using S.M.A.R.T. data to predict failures:

bash
$ sudo apt install smartmontools

# Quick health check
$ sudo smartctl -H /dev/sda

# Full S.M.A.R.T. data
$ sudo smartctl -a /dev/sda

# Run a short self-test
$ sudo smartctl -t short /dev/sda

# Enable SMART monitoring service
$ sudo systemctl enable --now smartmontools
22

Use Syncthing for Continuous Sync

Keep files in sync across multiple machines without a central server:

bash
$ sudo apt install syncthing

# Start Syncthing
$ systemctl --user enable --now syncthing

# Access the web UI
# Open http://localhost:8384 in your browser

# Create a systemd service for auto-start
$ sudo apt install syncthing-systemd

# Check sync status
$ systemctl --user status syncthing

Network Management

Essential networking tools and configurations for Debian administrators

23

Network Scanning with nmap

Discover devices, open ports, and services on your network:

bash
$ sudo apt install nmap

# Scan your local network
$ sudo nmap -sn 192.168.1.0/24

# Detailed port scan
$ sudo nmap -sS -p 1-1000 192.168.1.100

# OS detection
$ sudo nmap -O 192.168.1.100

# Scan common web ports
$ sudo nmap -p 80,443,8080,8443 192.168.1.0/24
24

Set Up a Local DNS Cache with Dnsmasq

Speed up DNS resolution by caching queries locally:

bash
$ sudo apt install dnsmasq

# Point to local DNS cache
$ echo "nameserver 127.0.0.1" | sudo tee /etc/resolv.conf

# Configure upstream DNS servers
$ sudo nano /etc/dnsmasq.conf

# Add these lines:
resolv-file=/etc/dnsmasq.resolv.conf
cache-size=1000
log-queries

# Set upstream DNS
$ echo "nameserver 1.1.1.1" | sudo tee /etc/dnsmasq.resolv.conf
$ echo "nameserver 8.8.8.8" | sudo tee -a /etc/dnsmasq.resolv.conf

$ sudo systemctl restart dnsmasq
25

Monitor Network Traffic with nethogs

See which processes are using the most bandwidth in real-time:

bash
$ sudo apt install nethogs

# Monitor default interface
$ sudo nethogs

# Monitor specific interface
$ sudo nethogs eth0

# Alternative: use iftop for connection-level view
$ sudo apt install iftop
$ sudo iftop -i eth0
26

Create a Wireless Access Point

Turn your Debian machine into a WiFi hotspot:

bash
$ sudo apt install hostapd dnsmasq iptables

# Configure hostapd
$ sudo nano /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=DebianHotspot
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
wpa=2
wpa_passphrase=yourpassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

$ sudo systemctl enable --now hostapd

Personalize Your System

Make Debian truly yours with these customization techniques

27

Customize GRUB Boot Menu

Change the default boot behavior, timeout, and appearance of GRUB:

bash
$ sudo nano /etc/default/grub

# Key settings:
GRUB_TIMEOUT=5              # Boot menu timeout
GRUB_DEFAULT=0              # Default entry
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_GFXMODE=1920x1080      # Boot menu resolution
GRUB_THEME=/boot/grub/themes/debian/theme.txt

# Apply changes
$ sudo update-grub
28

Set Up a Custom Kernel

Install a newer or specialized kernel for better hardware support:

bash
# Check current kernel
$ uname -r

# Install backports kernel (newer version)
$ sudo apt install linux-image-amd64 -t bookworm-backports

# Or install the cloud/server kernel
$ sudo apt install linux-image-cloud-amd64

# Remove old kernels
$ sudo apt autoremove --purge

# Reboot into new kernel
$ sudo reboot
29

Configure Power Management

Optimize power usage for laptops and desktops:

bash
# Install power management tools
$ sudo apt install tlp powertop

# Enable TLP
$ sudo systemctl enable --now tlp

# Run power profile analysis
$ sudo powertop

# Auto-tune power settings
$ sudo powertop --auto-tune

# Check CPU frequency governor
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Set to powersave for laptops
$ echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
30

Create Custom DEB Packages

Package your own applications for easy installation and management:

bash
$ sudo apt install dpkg-dev devscripts

# Create package structure
$ mkdir -p myapp/DEBIAN
$ mkdir -p myapp/usr/local/bin

# Copy your application
$ cp myapp-binary myapp/usr/local/bin/

# Create control file
$ cat > myapp/DEBIAN/control <<'EOF'
Package: myapp
Version: 1.0.0
Section: utils
Priority: optional
Architecture: amd64
Maintainer: Your Name 
Description: My custom application
 A brief description of what myapp does.
EOF

# Build the package
$ dpkg-deb --build myapp

# Install it
$ sudo dpkg -i myapp.deb

Quick Cheat Sheet

Essential commands every Debian user should know at their fingertips

Category Command Description
System Info uname -a Display full system information
System Info hostnamectl Show hostname and OS details
Package Mgmt apt list --installed List all installed packages
Package Mgmt apt search <name> Search for packages
Package Mgmt apt show <name> Show package details
Services systemctl list-units --failed List all failed services
Services journalctl -xe View system logs with errors
Networking ip addr Show network interfaces and IPs
Networking ss -tulpn List all listening ports
Storage lsblk List block devices
Storage df -h Check disk space usage
Processes htop Interactive process viewer
Users useradd -m -s /bin/bash <name> Create a new user with home dir
Permissions chmod 755 file Set read/write/execute permissions
Permissions chown user:group file Change file ownership
💡

Pro Tip: Create Your Own Cheat Sheet

Save frequently used commands in a ~/.bash_aliases file and source it from your ~/.bashrc. You can also use tools like thefuck to automatically correct mistyped commands.