Skip to content

Linux Command Reference

Quick reference for sysadmin commands that are easy to forget. All commands tested on Ubuntu 22.04+.


System Information

Command Description
hostname Show the hostname
head -n 1 /etc/os-release Show OS name and version
uname -a Kernel version, architecture, hostname
cat /proc/cpuinfo CPU details
lspci -tv List all PCI devices
lsusb -tv List all USB devices
lsmod List loaded kernel modules
env List all environment variables

Resources

Command Description
cat /proc/loadavg System load averages (1, 5, 15 min)
free -h RAM and swap usage
df -h Disk usage per filesystem
du -sh <dir> Size of a directory
fdisk -l List all partitions
swapon -s Show active swap partitions

Networking

Modern tools

ifconfig and netstat are deprecated. Ubuntu 18.04+ uses ip and ss from the iproute2 suite, which is installed by default.

Deprecated Modern replacement Description
ifconfig ip a Show all interfaces and IPs
ifconfig eth0 ip a show eth0 Show a specific interface
route -n ip route Show routing table
netstat -antp ss -antp All active connections with PID
netstat -tulpn ss -tulpn Listening TCP/UDP sockets

Services (systemctl)

Command Description
systemctl list-units List all active units
systemctl list-units -a List all units including inactive
systemctl list-units -a --state=inactive List only inactive units
systemctl status <service> Status of a specific service
journalctl -u <service> -f Follow logs for a service

Users

Command Description
w Who is logged in and what they are doing
last Login history
crontab -l List cron jobs for the current user
cut -d: -f1 /etc/passwd List all user accounts
cut -d: -f1 /etc/group List all groups
id <user> Show UID, GID, and group memberships

APT Package Management

apt <command>
Command Description
update Refresh package index from sources
upgrade Upgrade all installed packages
install <pkg> Install a package
remove <pkg> Remove a package (keep config files)
purge <pkg> Remove a package and its config files
autoremove Remove packages no longer needed
dist-upgrade Upgrade with dependency resolution (safe)
full-upgrade Upgrade including package removals if needed
check Check for broken dependencies
clean Remove cached package files
show <pkg> Show package details
list --installed List all installed packages