A practical, copy-ready reference for administering Debian-family Linux systems from the command line. Start with the safe everyday commands, then use the maintenance, networking, security, and recovery sections when you need more power.
DebianUbuntuLinux MintPop!_OSKali LinuxZorin OSelementary OSMX LinuxTailsRaspberry Pi OS
◆Where this works
Debian is the upstream distribution for a large ecosystem. Package-management examples are most portable across distributions that use APT and DEB packages. For deeper distribution overviews, see our Debian review, Linux Mint review, Pop!_OS review, and MX Linux review.
File, process, network, and shell commands often still work. Do not use apt/dpkg; each family has its own package manager.
Fast rule: If apt --version and dpkg --version work, the package commands in this guide are likely relevant. If systemctl fails, check which init system your distribution uses.
⌘Navigation & files
Everyday shell movement, file inspection, searching, copying, and text editing.
Move around
Show the current directory
pwd
List files with details; include hidden files
ls -lah
Change directory; use .. for the parent and ~ for home
cd /path/to/directory
Return to your home directory
cd ~
Create, copy & remove
Create a directory, including missing parents
mkdir -p project/{src,backup,logs}
Copy recursively and preserve useful metadata
cp -a source/ destination/
Move or rename a file
mv old-name.txt new-name.txt
Remove an empty directory
rmdir empty-directory
Delete a file after a prompt
rm -i file.txt
Read & search files
Page through a long text file; press q to exit
less /path/to/file
Watch new log lines as they are added
tail -f /var/log/syslog
Search recursively for text, showing line numbers
grep -RIn --color=auto 'search text' /path
Find files by name; case-insensitive
find /path -type f -iname '*pattern*'
Edit a file with Nano
nano /path/to/file
Safety: Avoid casually using rm -rf, especially with sudo, globs such as *, or a variable/path you have not printed and checked first.
⬢Packages: APT & DPKG
APT manages repositories and package dependencies. DPKG manages individual installed .deb packages. In scripts, prefer apt-get and apt-cache; interactively, apt is friendlier.
Daily package workflow
Refresh repository package indexes
sudo apt update
Upgrade installed packages without removing packages
sudo apt upgrade
Allow dependency changes, including removals when necessary
sudo apt full-upgrade
Install one or more packages
sudo apt install package-name
Remove package but retain its configuration files
sudo apt remove package-name
Remove package and its system-wide configuration
sudo apt purge package-name
Find & inspect packages
Search repository package descriptions
apt search keyword
Show package version, dependencies, and description
apt show package-name
List installed packages matching a name
apt list --installed 'package-name*'
Identify the installed package that owns a file
dpkg -S /usr/bin/command
List files installed by a package
dpkg -L package-name
Cleanup, repair & local DEBs
Remove automatically installed packages no longer needed
sudo apt autoremove
Clear downloaded package-cache files
sudo apt clean
Attempt to repair broken dependencies
sudo apt --fix-broken install
Configure packages left unconfigured
sudo dpkg --configure -a
Install a downloaded local .deb and resolve dependencies
sudo apt install ./package-file.deb
Recommended update routine: Run sudo apt update, review what will change with apt list --upgradable, then run sudo apt upgrade. Use full-upgrade only when you understand the proposed removals and installations.
♙Users, groups & permissions
Linux permissions hinge on ownership, groups, and mode bits. Verify identity and access before changing them.
Identity & accounts
Display the current user and groups
id
Create a normal interactive user
sudo adduser username
Add an existing user to a supplementary group
sudo usermod -aG groupname username
Set or change an account password
sudo passwd username
Switch to another user with a login shell
sudo -iu username
Ownership & modes
View permissions and ownership
ls -l /path/to/file
Change a file’s owner and group
sudo chown user:group /path/to/file
Change permissions symbolically
chmod u=rw,g=r,o= file.txt
Set a typical executable script mode
chmod 755 script.sh
Set a typical private-key mode
chmod 600 ~/.ssh/id_ed25519
Permission shorthand:r = read (4), w = write (2), and x = execute/traverse (1). Thus 755 means owner rwx, group r-x, others r-x.
⚙Processes & services
Use these tools to inspect resource use, control programs, and manage systemd services on most modern Debian-family systems.
Processes & resource use
Interactive process viewer; press q to exit
top
Find running processes by full command line
pgrep -af process-name
Show processes in a sortable table
ps aux --sort=-%mem | head
Request graceful termination by PID
kill PID
Force-kill only if graceful termination fails
kill -9 PID
systemd service control
Show detailed service state and recent output
systemctl status service-name
Start a service now
sudo systemctl start service-name
Restart a service after a configuration change
sudo systemctl restart service-name
Enable a service to start at boot
sudo systemctl enable --now service-name
Prevent a service from starting at boot and stop it
sudo systemctl disable --now service-name
Logs & scheduled work
Show the current boot’s journal errors
journalctl -b -p err
Follow a service’s logs in real time
sudo journalctl -u service-name -f
Edit the current user’s cron table
crontab -e
List the current user’s cron jobs
crontab -l
⌁Networking & remote access
Diagnose interfaces, routes, DNS, listening ports, and remote connections. Substitute your own host names, addresses, and interface names.
Inspect the network
Show addresses and interfaces
ip addr
Show routing table and default gateway
ip route
Show listening TCP/UDP sockets and owning processes
sudo ss -tulpn
Test reachability with four ICMP packets
ping -c 4 example.com
Query DNS records (install dnsutils if needed)
dig example.com
SSH & transfers
Connect to a remote machine through SSH
ssh user@host
Copy a local file to a remote host
scp local-file user@host:/remote/path/
Synchronize a directory over SSH; preview first with -n
Check capacity, mounts, disks, kernel details, memory, and boot/system logs before making storage changes.
Space & mounts
Show free space on mounted filesystems
df -hT
Summarize size of items in the current directory
du -sh ./*
List block devices, filesystem types, UUIDs, and mount points
lsblk -f
Show currently mounted filesystems
findmnt
Mount all valid /etc/fstab entries not already mounted
sudo mount -a
System & hardware details
Show distribution and version metadata
cat /etc/os-release
Show kernel, architecture, and host information
uname -a
Show memory and swap totals
free -h
Show PCI devices such as GPU, Ethernet, and audio
lspci -nn
Show USB devices
lsusb
Diagnostics & journal
Show kernel ring-buffer messages
dmesg -T | less
Show warnings and errors from the current boot
journalctl -b -p warning
Show the journal since one hour ago
journalctl --since '1 hour ago'
Follow all new journal entries live
sudo journalctl -f
⇄Archives, checksums & text
Compress and extract common archive formats, verify downloads, and chain text-processing commands.
Archives & compression
Create a gzip-compressed tar archive
tar -czf archive.tar.gz directory/
Extract a gzip-compressed tar archive
tar -xzf archive.tar.gz
List archive contents without extracting
tar -tzf archive.tar.gz
Create a ZIP archive recursively
zip -r archive.zip directory/
Extract a ZIP archive to a chosen directory
unzip archive.zip -d destination/
Integrity & pipelines
Calculate a SHA-256 checksum
sha256sum downloaded-file.iso
Verify checksums listed in a checksum file
sha256sum -c SHA256SUMS
Sort lines and remove duplicates
sort input.txt | uniq
Count lines, words, and bytes
wc -lwm file.txt
Write output to both the terminal and a file
command | tee output.txt
⛨Security, maintenance & recovery
Useful administration actions that deserve extra care. Back up important data and confirm paths, service names, and firewall rules before you alter a remote machine.
Privilege & firewall basics
Run a single command as root
sudo command
Open a root login shell; exit it when finished
sudo -i
Install uncomplicated firewall tooling
sudo apt install ufw
Allow SSH before enabling a remote-server firewall
sudo ufw allow OpenSSH
Enable UFW and show numbered rules
sudo ufw enable && sudo ufw status numbered
Boot, shutdown & repair
Reboot the system
sudo systemctl reboot
Power off the system
sudo systemctl poweroff
Check a filesystem only when the target is unmounted
sudo fsck -f /dev/sdXN
Reload systemd after editing a unit file
sudo systemctl daemon-reload
See failed systemd units
systemctl --failed
High-value checks
Check available upgrades without installing them
apt list --upgradable
View recent apt history
less /var/log/apt/history.log
See recent system reboot times
last reboot
List open files and connections on port 80
sudo lsof -i :80
Remote-server caution: Before enabling a firewall, restarting SSH, modifying networking, or rebooting a server, keep an existing session open and confirm you have console/out-of-band access if the change goes wrong.