Linux Commands for DevOps Engineer
Core System & Filesystem Management
1. ls -lrt: List files in long format, reverse time order (most recent last). Excellent for
seeing recently modified files.
2. cd -: Change to the previous working directory.
3. pwd -P: Print the present working directory, resolving all symlinks.
4. du -sh /path/to/dir: Disk Usage: Summarize human-readable disk usage for a
directory.
5. df -hT: Disk Free: Show filesystem disk space usage in human-readable format with
type.
6. find /path -name "*.log" -type f -mtime +7 -delete: Find files (e.g., .log) older than 7
days and delete them. Crucial for log rotation.
7. rsync -avz source/ dest/: Remote Sync: Efficiently copy files locally or remotely, only
transferring changes. Used for deployments, backups.
8. tar -czvf archive.tar.gz /path/to/dir: Create a gzipped tar archive. For backups and
packaging.
9. chmod -R 755 /path: Change mode: Recursively set file permissions.
10. chown -R user:group /path: Change owner: Recursively change file ownership.
Text Processing & Filtering
11. grep -r "pattern" /path: Global Regular Expression Print: Recursively search for a
pattern in files. Essential for log analysis.
12. awk '{print $1,$3}' filename: A powerful text processing tool for structured data. (e.g.,
print first and third columns).
13. sed -i 's/old_text/new_text/g' filename: Stream Editor: In-place substitution of text.
Great for configuration changes in scripts.
14. cut -d':' -f1 /etc/passwd: Extract sections from each line of files (e.g., show usernames
from passwd).
15. sort -u filename: Sort lines of text files, -u for unique lines.
16. uniq -c filename: Report or omit repeated lines, -c for count of occurrences.
17. head -n 10 file.log: Output the first part of files (e.g., first 10 lines).
18. tail -f file.log: Output the last part of files and follow (monitor) new lines being added.
Indispensable for live log monitoring.
19. wc -l filename: Word Count: Count lines in a file.
20. xargs -P 4 -I {} sh -c "command {}": Execute commands from standard input, often
used with find. (e.g., process multiple files in parallel).
Process Management & Monitoring
21. ps aux | grep process_name: Process Status: Display running processes, then filter.
22. top / htop: Display Linux processes, often used for real-time system monitoring. htop
is an enhanced interactive version.
23. kill -9 PID: Send a signal to a process (e.g., forcefully terminate a process).
24. nohup command &: Run a command immune to hangup signals and put it in the
background. Useful for long-running scripts.
25. jobs -l: List active jobs in the current shell.
26. bg %1 / fg %1: Bring a job to the background (bg) or foreground (fg).
27. nice -n 10 command: Run a command with a modified scheduling priority.
28. screen / tmux: Terminal multiplexers. Allow multiple terminal sessions within one
window, detach and reattach. Crucial for remote work.
29. systemctl status service_name: Manage systemd services (start, stop, restart, enable,
disable).
30. journalctl -u service_name -f: View and follow systemd service logs.
Networking & Connectivity
31. ping google.com: Send ICMP ECHO_REQUEST packets to network hosts. Basic
connectivity test.
32. netstat -tulnp: Network Statistics: Display network connections, routing tables,
interface statistics, etc. (-tulnp for TCP/UDP listening processes).
33. ss -tulpn: Socket Statistics: A faster, more modern replacement for netstat.
34. ip addr show: Show IP addresses and network interfaces (replacement for ifconfig).
35. ip route show: Show routing table (replacement for route -n).
36. curl -I http://example.com: Command Line URL: Transfer data with URL. -I for just
headers. Indispensable for API testing.
37. wget -r -l1 --no-parent http://example.com/dir/: Non-interactive network
downloader. Recursively download a website.
38. scp user@host:/path/to/remote/file /path/to/local/dir: Secure Copy Protocol:
Securely copy files between hosts.
39. ssh -L 8080:localhost:80 user@remote_host: Secure Shell: Connect to a remote
server. -L for local port forwarding.
40. nmap -sT -p 22,80,443 target_ip: Network Mapper: Network discovery and security
auditing. (-sT for TCP connect scan, -p for specific ports).
System Information & Troubleshooting
41. free -h: Display amount of free and used memory in the system.
42. uptime: Show how long the system has been running, number of users, and load
averages.
43. dmesg | less: Print or control the kernel ring buffer. Useful for hardware or driver
issues.
44. lsof -i :80: List Open Files: List open files and the processes that opened them. (-i :80
to find processes listening on port 80).
45. strace -p PID: System Call Trace: Trace system calls and signals. Advanced debugging.
46. iotop: Monitor I/O usage by processes/threads. Requires installation.
47. vmstat 1: Report virtual memory statistics. (Run every 1 second).
48. history: Display the command history list. Useful for recalling past commands.
49. alias devops="ls -lrt": Create temporary command aliases. For frequently used
complex commands.
50. sudo su -: Execute a command as another user (often root). Essential for administrative
tasks.