50 Must-Know Linux Commands for DevOps & Cloud Engineers
Welcome to my blog! 🚀 Whether you're a DevOps engineer, Cloud enthusiast, or Linux beginner, mastering these 50 essential Linux commands will boost your productivity and make you a command-line ninja!
📂 File & Directory Operations
1. ls – List Directory Contents
ls -la /home/user # Show hidden files with details
Tip: Use -l for a detailed view and -a to see hidden files.
2. cd – Change Directory
cd /var/log # Move to the log directory
Tip: cd ~ takes you home, and cd - goes back to the previous directory.
3. pwd – Print Working Directory
pwd # Shows the current directory path
Tip: Always check pwd before running critical commands!
4. mkdir – Make Directory
mkdir -p projects/{dev,test,prod} # Create nested directories
Tip: -p creates parent directories if they don’t exist.
5. rm – Remove Files/Directories
rm -rf old_backups/ # ⚠️ Caution: Force delete a directory
Tip: Double-check before using -rf!
6. cp – Copy Files
cp -r source_folder/ destination/ # Recursive copy
Tip: Always verify paths before copying.
7. mv – Move/Rename Files
mv old_name.txt new_name.txt # Rename a file
Tip: mv is also used for moving files across directories.
8. touch – Create Empty File
touch new_file.txt
Tip: Also updates file timestamps if it exists.
9. find – Search Files
find / -name "*.log" 2>/dev/null # Find all log files
Tip: Use 2>/dev/null to suppress permission errors.
10. stat – File Status
stat script.sh # Show file details (permissions, size, etc.)
Tip: Great for debugging file-related issues.
📝 File Viewing & Editing
11. cat – Concatenate & Display Files
cat /etc/os-release # Show file content
💡 Style Tip: Use cat > file.txt to create a file on the fly.
12. less / more – Paged File Viewing
less /var/log/syslog # Scrolla
Tip: less is better than more (supports backward navigation).
13. head – Show First Lines
head -n 5 access.log # Display first 5 lines
Tip: Useful for quick log checks.
14. tail – Show Last Lines
tail -f /var/log/nginx/error.log # Follow log in real-time
Tip: -f is a must-know for log monitoring!
15. grep – Search Text
grep -i "error" /var/log/syslog # Case-insensitive search
Tip: Combine with | (pipe) for powerful filtering.
16. awk – Text Processing
awk '{print $1}' access.log # Extract first column
Tip: A Swiss Army knife for text manipulation.
17. sed – Stream Editor
sed 's/foo/bar/g' file.txt # Replace all 'foo' with 'bar'
Tip: Great for bulk text replacements.
18. nano / vim – Text Editors
vim /etc/hosts # Edit hosts file
Tip: Learn basic vim commands (:wq, i, ESC).
🛠️ System & Process Management
19. ps – Process Status
ps aux | grep nginx # Find Nginx processes
Tip: aux shows all running processes.
20. top / htop – Process Monitor
htop # Interactive process viewer
Tip: htop is a must-install for DevOps!
21. kill – Terminate Process
kill -9 1234 # Force kill PID 1234
Tip: -9 is a last resort (SIGKILL).
22. systemctl – Manage Services
systemctl restart nginx # Restart Nginx
Tip: Use status, start, stop, enable.
23. journalctl – View System Logs
journalctl -u docker --since "1 hour ago"
Tip: Essential for debugging services.
24. df – Disk Space Usage
df -h # Human-readable disk space
Tip: -h makes sizes readable (MB/GB).
25. du – Directory Space Usage
du -sh /var/log # Total size of /var/log
Tip: -s for summary, -h for human-readable.
🌐 Networking & Connectivity
Recommended by LinkedIn
26. ping – Test Connectivity
ping google.com
Tip: Use -c 4 to limit pings.
27. curl / wget – Download Files
curl -O https://example.com/file.zip
Tip: curl is more versatile for APIs.
28. netstat / ss – Network Stats
ss -tulnp # Show listening ports
Tip: ss is the modern replacement for netstat.
29. ifconfig / ip – Network Interfaces
ip a # Show all IP addresses
Tip: ip is the new standard (ifconfig is deprecated).
30. traceroute / mtr – Network Path
mtr google.com # Real-time network diagnostics
Tip: mtr combines ping + traceroute.
🔐 Permissions & Users
31. chmod – Change Permissions
chmod 755 script.sh # rwxr-xr-x
Tip: 755 for scripts, 600 for sensitive files.
32. chown – Change Ownership
chown user:group file.txt
Tip: Often needed after sudo operations.
33. sudo – Run as Superuser
sudo apt update
Tip: With great power comes great responsibility!
34. passwd – Change Password
passwd # Change current user's password
Tip: Use sudo passwd <user> for other users.
35. useradd / usermod – User Management
sudo useradd -m newuser # Create user with home dir
Tip: -m creates a home directory.
📦 Package Management
36. apt / yum / dnf – Package Managers
sudo apt install docker-ce
Tip: Know your distro’s package manager!
37. dpkg / rpm – Manual Package Install
sudo dpkg -i package.deb
Tip: Useful for manual .deb/.rpm installs.
⚙️ Advanced & DevOps-Specific
38. tar – Archive Files
tar -czvf backup.tar.gz /data
Tip: -czvf = Create, Zip, Verbose, File
39. scp – Secure Copy
scp file.txt user@remote:/path/
Tip: Use -r for directories.
40. rsync – Remote Sync
rsync -avz /local/ user@remote:/backup/
Tip: Best for backups & syncs!
41. crontab – Schedule Jobs
crontab -e # Edit cron jobs
Tip: Use @reboot for startup scripts.
42. env – Environment Variables
env | grep PATH
Tip: Modify ~/.bashrc for permanent changes.
43. history – Command History
history | grep "ssh"
Tip: !<number> re-runs a command from history.
44. alias – Create Shortcuts
alias ll='ls -la'
Tip: Add aliases to ~/.bashrc.
45. ssh – Secure Shell
ssh user@server -p 2222
Tip: Use -i for key-based auth.
46. tmux / screen – Terminal Multiplexer
tmux new -s session1
Tip: Lifesaver for long-running tasks!
47. lsof – List Open Files
lsof -i :80 # Find processes using port 80
Tip: Debug "port already in use" errors.
48. strace – Debug System Calls
strace -f -p <PID>
Tip: Advanced debugging tool.
49. dig / nslookup – DNS Queries
dig google.com
Tip: +short for quick DNS checks.
50. man – Manual Pages
man grep # Show grep documentation
Tip: RTFM! (Read The Fine Manual)
🎉 Final Thoughts
Mastering these 50 Linux commands will make you a command-line pro 🚀.
🔹 Want more? Check out my full blog with detailed explanations & cheat sheets!
🔹 Which command is your favorite? Let me know in the comments!
Happy Learning! 🐧💻