Alexa Web Servers Blog

100 Essential Linux Commands Every Sysadmin Should Know

Consejos prácticos sobre WordPress, servidores, rendimiento, seguridad y mantenimiento para negocios que quieren una presencia online seria.

Publicado el July 17, 2026

For anyone managing a Linux server — whether it is a cloud VPS, a dedicated box, or a Raspberry Pi at home — knowing the right commands can save hours of frustration. This guide covers the 100 essential Linux commands every sysadmin should know, grouped by category. Bookmark it, print it, or grab our Ubuntu Server Commands Cheat Sheet for quick offline reference.

1. File and Directory Operations

ls -la — List all files with details (permissions, size, date). Always start here.
cd /path — Change directory.
pwd — Print working directory. Where am I?
mkdir -p a/b/c — Create nested directories in one command.
rm -rf dir/ — Remove directory and all contents. Use with care.
cp -r source dest — Copy recursively.
mv source dest — Move or rename.
touch file — Create empty file or update timestamp.
find / -name "*.log" — Find files matching a pattern.
locate filename — Faster than find, uses a prebuilt index.
tree -L 2 — Show directory tree, 2 levels deep.

2. Viewing and Editing Files

cat file — Dump file contents to terminal.
less file — Scroll through files page by page (press q to quit).
head -n 20 file — Show first 20 lines.
tail -n 20 file — Show last 20 lines.
tail -f /var/log/syslog — Follow logs in real time.
grep "error" /var/log/syslog — Search inside files. Combine with -i for case-insensitive, -r for recursive.
wc -l file — Count lines in a file.
diff file1 file2 — Show differences between two files.
sort file — Sort lines alphabetically.
uniq — Remove duplicate adjacent lines. Often paired with sort | uniq.

3. File Permissions and Ownership

chmod 755 script.sh — Set permissions (rwx r-x r-x).
chmod +x script.sh — Make executable.
chown user:group file — Change owner and group.
umask 022 — Set default permission mask for new files.
ls -l — Check current permissions.
stat file — Detailed file information including permissions, ownership, timestamps.

4. Disk and Storage

df -h — Show disk usage in human-readable format.
du -sh /var — Show total size of a directory.
du -h --max-depth=1 — Size of each subdirectory, one level deep.
lsblk — List block devices (disks, partitions).
fdisk -l — List partition tables.
mount /dev/sdb1 /mnt — Mount a partition.
umount /mnt — Unmount.
blkid — Show UUIDs of all block devices.
fallocate -l 1G testfile — Create a 1GB file instantly (for swap or testing).
smartctl -a /dev/sda — Check disk health (requires smartmontools).

5. Package Management (APT)

apt update — Refresh package index.
apt upgrade — Upgrade all packages.
apt install nginx — Install a package.
apt remove nginx — Remove a package.
apt purge nginx — Remove package and config files.
apt autoremove — Remove unused dependencies.
dpkg -i package.deb — Install a .deb file directly.
dpkg -l | grep nginx — Check if a package is installed.
apt list --upgradable — Show packages that can be upgraded.
add-apt-repository ppa:name — Add a PPA repository.

6. System Information and Monitoring

top — Real-time process viewer. Press q to quit.
htop — Better top with color and scrolling (install separately).
ps aux — List all running processes.
ps aux | grep nginx — Find a specific process.
kill -9 PID — Force kill a process.
killall nginx — Kill all processes by name.
systemctl status nginx — Check service status.
systemctl start/stop/restart nginx — Control services.
systemctl enable nginx — Start service on boot.
journalctl -u nginx -n 50 — Show last 50 log lines for a service.
uptime — How long has the server been running?
who — Who is logged in?
last — Login history.
free -h — Memory usage (RAM + swap).
uname -a — Kernel version and system info.
lscpu — CPU details.
nproc — Number of CPU cores.

7. Networking

ip a — Show all network interfaces and IP addresses.
ip r — Show routing table.
ss -tulpn — Show listening ports and the processes using them.
ping -c 4 google.com — Check network connectivity.
curl ifconfig.me — Show your public IP.
curl -I https://example.com — Fetch HTTP headers only.
wget https://example.com/file — Download a file.
scp file user@host:/path — Copy files over SSH.
rsync -avz source/ user@host:/dest/ — Sync directories over SSH.
ssh user@host — Connect to a remote server.
ssh-keygen -t ed25519 — Generate SSH key pair.
ssh-copy-id user@host — Copy public key to remote server.
dig example.com — Detailed DNS query.
nslookup example.com — DNS lookup.
traceroute example.com — Trace network path.
mtr example.com — Combine traceroute + ping continuous.
tcpdump -i eth0 port 80 — Capture network packets (use with care).
nmap -sV localhost — Scan open ports on local machine.

8. Compression and Archiving

tar -czvf archive.tar.gz /path — Create a .tar.gz archive.
tar -xzvf archive.tar.gz — Extract a .tar.gz archive.
tar -cjvf archive.tar.bz2 /path — Create a .tar.bz2 archive.
zip -r archive.zip /path — Create a zip archive.
unzip archive.zip — Extract a zip archive.
gzip file — Compress a file.
gunzip file.gz — Decompress.
zcat file.gz — View compressed file contents without extracting.

9. User Management

useradd -m -s /bin/bash username — Create a new user with home directory.
passwd username — Set or change password.
usermod -aG sudo username — Add user to sudo group.
deluser username — Remove a user.
groups username — Show groups a user belongs to.
id username — Show user ID, group ID, and groups.
sudo -l — List sudo privileges for current user.
visudo — Edit sudoers file safely.

10. Process Management and Scheduling

nohup command & — Run command immune to hangups, in background.
screen — Terminal multiplexer (reattachable sessions).
tmux — Modern alternative to screen.
at 09:00 -f script.sh — Schedule a one-time job.
crontab -e — Edit cron jobs.
crontab -l — List cron jobs.
nice -n 10 command — Run with lower priority.

11. Text Processing with Pipes

command | grep pattern — Filter output.
command | awk '{print $2}' — Print second column.
command | sed 's/old/new/g' — Find and replace in stream.
command | cut -d: -f1 — Cut by delimiter, first field.
command | sort | uniq -c — Count unique occurrences.
command | tee file.txt — Show output and save to file simultaneously.

12. Security Essentials

ufw status verbose — Firewall status (Uncomplicated Firewall).
ufw allow 22/tcp — Allow SSH through firewall.
ufw enable — Enable firewall.
fail2ban-client status — Check fail2ban status.
lastb — Show failed login attempts.
openssl s_client -connect example.com:443 — Check SSL certificate details.

Also see: Our 100+ Essential Kubernetes Commands guide for container orchestration.


Master these commands and you can handle 95% of daily sysadmin tasks. Keep this guide handy — or better yet, download our Ubuntu Server Commands Cheat Sheet ($2.99) with all 100+ commands in a printable format. No fluff, no ads, just commands.

We release new cheat sheets regularly — check our full product catalog for references on Docker, Linux security, Kubernetes, Python, and more.

Also see: Our 80+ Essential Docker Commands guide for container and deployment commands.

💬 ¿Hablamos ahora?