Essential Linux commands every sysadmin should know. Organized by category for quick reference.
File & Directory
| Command | Description |
|---|---|
ls | List directory contents |
ls -la | List all files with permissions and sizes |
cd | Change directory |
pwd | Print working directory |
mkdir -p | Create directory and parents |
rm -rf | Remove files/directories recursively (use with caution) |
cp -r | Copy files/directories recursively |
mv | Move or rename files |
find . -name | Find files by name recursively |
locate | Find files using index (fast) |
touch | Create empty file or update timestamp |
ln -s | Create symbolic link |
du -sh | Show disk usage of directory |
df -h | Show disk free space |
stat | Show file metadata (size, inode, timestamps) |
File Viewing & Editing
| Command | Description |
|---|---|
cat | Print file contents |
less | Page through file (q to quit) |
head -n 20 | Show first N lines of file |
tail -n 20 | Show last N lines of file |
tail -f | Follow file in real time (logs) |
grep -rn | Search text recursively with line numbers |
awk | Pattern scanning and processing language |
sed | Stream editor — find/replace in files |
wc -l | Count lines in file |
sort | Sort lines alphabetically or numerically |
uniq | Remove duplicate lines |
cut -d: -f1 | Cut fields from delimited text |
diff | Compare two files line by line |
vim / nano | Terminal text editors |
Permissions & Ownership
| Command | Description |
|---|---|
chmod 755 | Set file permissions (rwxr-xr-x) |
chown user:group | Change file owner and group |
umask | Set default permission mask |
sudo | Execute command as superuser |
su - | Switch to root user |
passwd | Change user password |
id | Show current user UID/GID/groups |
groups | List user group memberships |
Process Management
| Command | Description |
|---|---|
ps aux | List all running processes |
top / htop | Interactive process monitor |
kill -9 PID | Force kill process by PID |
killall name | Kill all processes by name |
pkill | Kill processes matching pattern |
jobs | List background jobs in current shell |
bg / fg | Resume job in background / foreground |
nohup | Run command immune to hangups |
nice / renice | Set process CPU priority |
lsof | List open files and sockets |
strace | Trace system calls of a process |
Networking
| Command | Description |
|---|---|
ip addr | Show network interfaces and IPs |
ip route | Show routing table |
ping -c 4 | Test connectivity to host |
traceroute | Trace network path to host |
nslookup / dig | DNS lookup utilities |
curl -I | Fetch HTTP headers from URL |
wget | Download files from web |
ss -tulpn | Show open ports and listening services |
netstat -an | Show network connections |
iptables -L | List firewall rules |
ssh user@host | Connect to remote host via SSH |
scp src dst | Secure copy files over SSH |
rsync -avz | Sync files/dirs with progress and compression |
nmap -sV | Scan host ports and service versions |
tcpdump -i eth0 | Capture network packets on interface |
System Info & Hardware
| Command | Description |
|---|---|
uname -a | Print kernel version and system info |
uptime | System uptime and load average |
free -h | Show RAM usage in human-readable form |
vmstat 1 | Virtual memory stats every second |
iostat | CPU and disk I/O statistics |
lscpu | Display CPU architecture information |
lsblk | List block devices (disks, partitions) |
lsusb / lspci | List USB and PCI devices |
dmesg | tail | Show kernel ring buffer / boot messages |
hostnamectl | Show or set system hostname and OS info |
timedatectl | Show or set system time and timezone |
Package Management
| Command | Description |
|---|---|
apt update && apt upgrade | Update package list and upgrade (Debian/Ubuntu) |
apt install pkg | Install a package (Debian/Ubuntu) |
apt remove pkg | Remove a package |
dpkg -l | List all installed packages (Debian) |
yum / dnf install | Install package (RHEL/CentOS/Fedora) |
rpm -qa | List all installed RPM packages |
Services & systemd
| Command | Description |
|---|---|
systemctl status svc | Check service status |
systemctl start svc | Start a service |
systemctl stop svc | Stop a service |
systemctl restart svc | Restart a service |
systemctl enable svc | Enable service at boot |
systemctl disable svc | Disable service at boot |
journalctl -u svc | View logs for a specific service |
journalctl -f | Follow system journal in real time |
crontab -e | Edit user cron jobs |
Archives & Compression
| Command | Description |
|---|---|
tar -czvf out.tgz dir/ | Create gzipped tarball |
tar -xzvf file.tgz | Extract gzipped tarball |
zip -r out.zip dir/ | Create zip archive |
unzip file.zip | Extract zip archive |
gzip / gunzip | Compress / decompress .gz files |
Shell & Scripting
| Command | Description |
|---|---|
echo | Print text to stdout |
export VAR=val | Set environment variable |
env | List all environment variables |
alias | Create command shortcuts |
history | Show command history |
source / . | Execute script in current shell |
bash script.sh | Run a shell script |
which / whereis | Find location of a command binary |
man cmd | Show manual page for command |
xargs | Build and execute commands from stdin |
tee | Read from stdin, write to stdout and file |