Top 200 Linux Commands for DevOps: The Complete Reference Guide
📅 Published: June 2026
⏱️ Estimated Reading Time: 30 minutes
🏷️ Tags: Linux Commands, DevOps, Command Line, System Administration, Shell Scripting
Introduction: Why These Commands Matter
Linux is the operating system of the cloud. Over 90% of servers run Linux. Every DevOps engineer must be comfortable at the command line. You don't need to memorize every command, but you need to know what's possible and how to find what you need.
This guide organizes 200 essential Linux commands by category. Each command includes a practical example showing exactly how to use it.
Part 1: File System Navigation (15 commands)
| Command | Purpose | Example |
|---|---|---|
pwd | Print working directory | pwd → /home/user |
ls | List files and directories | ls -la (detailed list) |
cd | Change directory | cd /var/log |
tree | Display directory tree | tree -L 2 (2 levels deep) |
mkdir | Create directory | mkdir -p dir1/dir2 (create parents) |
rmdir | Remove empty directory | rmdir emptydir |
touch | Create empty file or update timestamp | touch newfile.txt |
rm | Remove files or directories | rm -rf dir (force recursive) |
cp | Copy files or directories | cp -r source dest |
mv | Move or rename files | mv old.txt new.txt |
ln | Create links | ln -s target link (symbolic) |
stat | Display file status | stat filename |
file | Determine file type | file script.sh |
du | Disk usage | du -sh * (human readable) |
df | Disk free space | df -h (human readable) |
Part 2: File Viewing and Editing (15 commands)
| Command | Purpose | Example |
|---|---|---|
cat | Concatenate and display files | cat file.txt |
less | View file page by page | less largefile.log |
more | View file one screen at a time | more file.txt |
head | Display first lines | head -20 file.txt |
tail | Display last lines | tail -f app.log (follow) |
tac | Display file in reverse | tac file.txt |
nl | Number lines | nl file.txt |
wc | Word count | wc -l file.txt (lines only) |
grep | Search for patterns | grep -r "error" /var/log/ |
egrep | Extended grep | egrep "error|fail" log |
fgrep | Fixed string grep | fgrep "exact string" file |
sed | Stream editor | sed 's/old/new/g' file.txt |
awk | Text processing | awk '{print $1}' file.txt |
sort | Sort lines | sort -rn file.txt (reverse numeric) |
uniq | Remove duplicate lines | sort file.txt | uniq -c |
Part 3: File Permissions and Ownership (10 commands)
| Command | Purpose | Example |
|---|---|---|
chmod | Change file permissions | chmod 755 script.sh |
chown | Change file owner | chown user:group file.txt |
chgrp | Change group ownership | chgrp developers file.txt |
umask | Set default permissions | umask 022 |
lsattr | List file attributes | lsattr file.txt |
chattr | Change file attributes | chattr +i file.txt (immutable) |
getfacl | Get file ACL | getfacl file.txt |
setfacl | Set file ACL | setfacl -m u:user:rw file.txt |
sudo | Execute as superuser | sudo systemctl restart nginx |
su | Switch user | su - username |
Part 4: Process Management (15 commands)
| Command | Purpose | Example |
|---|---|---|
ps | Process status | ps aux (all users, detailed) |
top | Dynamic process view | top then M (sort by memory) |
htop | Interactive process viewer | htop (install if needed) |
pgrep | Find processes by name | pgrep -l nginx |
pidof | Find PID of process | pidof nginx |
kill | Terminate process | kill -9 PID (force) |
pkill | Kill by name | pkill -f "python app.py" |
killall | Kill all processes by name | killall nginx |
nice | Set process priority | nice -n 19 slowjob |
renice | Change process priority | renice -n 10 -p 12345 |
nohup | Run immune to hangups | nohup longjob & |
bg | Send to background | bg %1 |
fg | Bring to foreground | fg %1 |
jobs | List background jobs | jobs -l |
wait | Wait for process to finish | wait PID |
Part 5: System Information (15 commands)
| Command | Purpose | Example |
|---|---|---|
uname | System information | uname -a (all) |
hostname | Show/set hostname | hostname |
whoami | Current user | whoami |
id | User identity | id |
uptime | System uptime and load | uptime |
w | Who is logged in | w |
who | Who is logged in | who -a |
last | Last logins | last -10 |
lastlog | Last login per user | lastlog |
dmesg | Kernel messages | dmesg | tail -20 |
free | Memory usage | free -h |
vmstat | Virtual memory stats | vmstat 2 5 (2 sec, 5 times) |
iostat | I/O statistics | iostat -x 1 |
lscpu | CPU information | lscpu |
lsblk | Block devices | lsblk |
Part 6: Network Commands (20 commands)
| Command | Purpose | Example |
|---|---|---|
ip | Show/manage network interfaces | ip addr show |
ifconfig | Configure network interfaces | ifconfig eth0 (legacy) |
ping | Test connectivity | ping -c 4 google.com |
traceroute | Trace network path | traceroute google.com |
tracepath | Trace path with MTU discovery | tracepath google.com |
mtr | My traceroute (ping + traceroute) | mtr google.com |
netstat | Network statistics | netstat -tulpn |
ss | Socket statistics | ss -tulpn (modern netstat) |
nmap | Network scanner | nmap -p 80 192.168.1.1 |
nc | Netcat (network tool) | nc -zv google.com 80 |
telnet | Test port connectivity | telnet google.com 80 |
curl | Transfer data | curl -I https://example.com |
wget | Download files | wget https://example.com/file.zip |
dig | DNS lookup | dig google.com |
nslookup | DNS query | nslookup google.com |
host | DNS lookup | host google.com |
arp | ARP cache | arp -a |
route | Routing table | route -n |
iptables | Firewall rules | iptables -L -n |
ufw | Uncomplicated firewall | ufw status |
Part 7: Package Management (15 commands)
Debian/Ubuntu (APT)
| Command | Purpose | Example |
|---|---|---|
apt update | Update package list | sudo apt update |
apt upgrade | Upgrade packages | sudo apt upgrade -y |
apt install | Install package | sudo apt install nginx |
apt remove | Remove package | sudo apt remove nginx |
apt purge | Remove with config | sudo apt purge nginx |
apt search | Search packages | apt search nginx |
apt show | Show package info | apt show nginx |
apt list | List installed | apt list --installed |
apt autoremove | Remove unused | sudo apt autoremove |
dpkg | Package manager | dpkg -l | grep nginx |
Red Hat/CentOS (YUM/DNF)
| Command | Purpose | Example |
|---|---|---|
yum update | Update packages | sudo yum update |
yum install | Install package | sudo yum install nginx |
yum remove | Remove package | sudo yum remove nginx |
yum search | Search packages | yum search nginx |
yum info | Package info | yum info nginx |
dnf | Modern yum | sudo dnf install nginx |
rpm | RPM package manager | rpm -qa | grep nginx |
Part 8: Compression and Archiving (10 commands)
| Command | Purpose | Example |
|---|---|---|
tar | Archive files | tar -czf archive.tar.gz dir/ |
gzip | Compress files | gzip file.txt |
gunzip | Decompress files | gunzip file.txt.gz |
zip | Package and compress | zip archive.zip file1 file2 |
unzip | Extract zip files | unzip archive.zip |
bzip2 | Compress (better ratio) | bzip2 file.txt |
bunzip2 | Decompress bzip2 | bunzip2 file.txt.bz2 |
xz | Compress (high ratio) | xz file.txt |
unxz | Decompress xz | unxz file.txt.xz |
zcat | Display compressed file | zcat file.gz |
Part 9: Text Processing (20 commands)
| Command | Purpose | Example |
|---|---|---|
cut | Extract columns | cut -d',' -f1,3 file.csv |
paste | Merge lines | paste file1 file2 |
tr | Translate characters | tr 'a-z' 'A-Z' < file.txt |
sort | Sort lines | sort -k2 -n data.txt |
uniq | Unique lines | sort file | uniq -d (duplicates) |
comm | Compare files | comm file1 file2 |
diff | Compare files line by line | diff -u file1 file2 |
cmp | Compare files byte by byte | cmp file1 file2 |
patch | Apply diff file | patch < file.patch |
join | Join lines from two files | join file1 file2 |
split | Split file into pieces | split -l 1000 large.log |
csplit | Split based on pattern | csplit file '/pattern/' |
expand | Convert tabs to spaces | expand -t 4 file.txt |
unexpand | Convert spaces to tabs | unexpand -t 4 file.txt |
pr | Format for printing | pr -l 60 file.txt |
fmt | Format text paragraphs | fmt -w 80 file.txt |
fold | Wrap lines | fold -w 80 file.txt |
rev | Reverse lines | rev file.txt |
shuf | Shuffle lines | shuf file.txt |
seq | Generate sequences | seq 1 10 |
Part 10: Finding and Searching (10 commands)
| Command | Purpose | Example |
|---|---|---|
find | Find files | find /home -name "*.txt" |
locate | Find by database | locate nginx.conf |
updatedb | Update locate DB | sudo updatedb |
which | Locate command | which nginx |
whereis | Locate binary/source/man | whereis nginx |
type | Command type | type ls |
whatis | One-line description | whatis ls |
apropos | Search man pages | apropos "copy file" |
grep | Search file content | grep -r "TODO" --include="*.py" |
ack | Better grep for code | ack "function" (install) |
Part 11: Environment and Shell (10 commands)
| Command | Purpose | Example |
|---|---|---|
env | Show environment variables | env |
export | Set environment variable | export PATH=$PATH:/usr/local/bin |
unset | Remove variable | unset TEMP_VAR |
echo | Print to stdout | echo $PATH |
printenv | Print environment | printenv HOME |
alias | Create command alias | alias ll='ls -la' |
unalias | Remove alias | unalias ll |
source | Execute file in current shell | source ~/.bashrc |
. | Same as source | . ~/.bashrc |
history | Command history | history | grep ssh |
Part 12: User Management (10 commands)
| Command | Purpose | Example |
|---|---|---|
useradd | Create user | sudo useradd -m username |
usermod | Modify user | sudo usermod -aG sudo username |
userdel | Delete user | sudo userdel -r username |
passwd | Change password | passwd (self) or sudo passwd user |
groupadd | Create group | sudo groupadd developers |
groupmod | Modify group | sudo groupmod -n newname oldname |
groupdel | Delete group | sudo groupdel groupname |
groups | Show user groups | groups username |
id | Show user identity | id username |
who | Who is logged in | who -a |
Part 13: SSH and Remote Access (10 commands)
| Command | Purpose | Example |
|---|---|---|
ssh | Secure shell | ssh user@hostname |
ssh-keygen | Generate SSH keys | ssh-keygen -t rsa -b 4096 |
ssh-copy-id | Copy public key | ssh-copy-id user@host |
scp | Secure copy | scp file.txt user@host:/path/ |
rsync | Remote sync | rsync -avz /local/ user@host:/remote/ |
sftp | Secure FTP | sftp user@host |
ssh-agent | SSH key manager | eval $(ssh-agent) |
ssh-add | Add key to agent | ssh-add ~/.ssh/id_rsa |
ssh-keyscan | Get host public key | ssh-keyscan hostname |
screen | Terminal multiplexer | screen -S session |
Part 14: System Administration (20 commands)
| Command | Purpose | Example |
|---|---|---|
systemctl | Systemd service manager | systemctl status nginx |
journalctl | Systemd logs | journalctl -u nginx -f |
service | Service management | service nginx restart (legacy) |
crontab | Schedule jobs | crontab -e |
at | One-time scheduled job | echo "backup.sh" | at 2am |
systemd-analyze | Boot performance | systemd-analyze blame |
timedatectl | Time and date | timedatectl set-timezone UTC |
date | Show/Set date | date "+%Y-%m-%d" |
cal | Calendar | cal 2026 |
sleep | Delay execution | sleep 5 && echo "done" |
watch | Execute periodically | watch -n 1 "df -h" |
time | Measure execution time | time ./script.sh |
xargs | Build command lines | find . -name "*.log" | xargs rm |
tee | Redirect to file and stdout | echo "text" | tee file.txt |
script | Record terminal session | script session.log |
screen | Terminal multiplexer | screen |
tmux | Terminal multiplexer | tmux new -s mysession |
logger | Log message to syslog | logger "Backup completed" |
wall | Send message to all users | wall "System will reboot" |
shutdown | Shutdown system | sudo shutdown -h now |
Part 15: Disk and Filesystem (10 commands)
| Command | Purpose | Example |
|---|---|---|
fdisk | Partition table manipulator | sudo fdisk -l |
lsblk | List block devices | lsblk |
blkid | Block device attributes | sudo blkid |
mount | Mount filesystem | mount /dev/sdb1 /mnt |
umount | Unmount filesystem | umount /mnt |
fsck | Filesystem check | sudo fsck /dev/sda1 |
mkfs | Create filesystem | sudo mkfs.ext4 /dev/sdb1 |
dd | Convert and copy | dd if=/dev/sda of=backup.img |
badblocks | Check for bad blocks | sudo badblocks -v /dev/sda |
smartctl | SMART disk health | sudo smartctl -a /dev/sda |
Part 16: Security Commands (10 commands)
| Command | Purpose | Example |
|---|---|---|
openssl | Cryptography toolkit | openssl genrsa -out key.pem 2048 |
gpg | GNU Privacy Guard | gpg -c secret.txt (encrypt) |
md5sum | MD5 checksum | md5sum file.txt |
sha256sum | SHA256 checksum | sha256sum file.txt |
chmod | Change permissions | chmod 600 ~/.ssh/id_rsa |
chown | Change ownership | chown user:group file |
umask | Default permissions | umask 027 |
fail2ban-client | Fail2ban manager | fail2ban-client status sshd |
auditctl | Audit system calls | auditctl -l |
selinux | SELinux commands | getenforce |
Part 17: Networking Advanced (5 commands)
| Command | Purpose | Example |
|---|---|---|
tcpdump | Packet capture | sudo tcpdump -i eth0 port 80 |
tcpflow | TCP session capture | tcpflow -i eth0 port 80 |
nethogs | Per-process network | sudo nethogs |
iftop | Bandwidth usage | sudo iftop |
iptraf | Network statistics | sudo iptraf-ng |
Part 18: Performance Monitoring (5 commands)
| Command | Purpose | Example |
|---|---|---|
sar | System activity reporter | sar -u 1 3 (CPU every 1 sec) |
mpstat | CPU statistics | mpstat -P ALL 1 |
pidstat | Process statistics | pidstat 1 |
perf | Linux profiling | perf top |
strace | Trace system calls | strace -p PID |
Quick Reference: Most Important Commands
If you remember only 20 commands, make them these:
# Navigation ls -la # List everything cd /path # Change directory pwd # Where am I? # File operations cat file # View file less file # Page through file tail -f log # Follow log grep pattern # Search cp -r src dst # Copy mv old new # Move/rename rm -rf dir # Delete (careful!) # Processes ps aux # See running processes top # Real-time processes kill -9 PID # Force kill # Network ping host # Test connectivity curl URL # Test web endpoint ss -tulpn # See listening ports # System df -h # Disk space free -h | Memory usage uptime # Load average # Permissions chmod 755 file # Change permissions sudo command # Run as root # Package management apt update # Update package list (Debian) apt install pkg # Install package (Debian) yum install pkg # Install package (RHEL) # Help man command # Read manual command --help # Quick help
How to Remember Commands
Use man – The manual is your friend
man ls
Use history – See what you've run before
history | grep nginx
Use alias – Create shortcuts
alias ll='ls -la' alias gs='git status'
Use tldr – Simplified man pages (install first)
tldr tarLearn More
Practice Linux commands with hands-on exercises in our interactive labs:
https://devops.trainwithsky.com/
Comments
Post a Comment