Linux for DevOps Engineers: Essential Guide
Introduction
Linux is the backbone of modern DevOps engineering. Whether you’re managing servers, automating deployments, or troubleshooting infrastructure, Linux skills are essential. This guide covers Linux commands and tasks from basic to expert level, helping you navigate system administration, security, automation, and cloud environments.
Linux Commands for DevOps Engineers
System Monitoring & Performance
- top – Display real-time system resource usage
- htop – Interactive process viewer
- uptime – Show system uptime
- free -m – Display memory usage
- df -h – Show disk space usage
- du -sh – Get directory size
- iostat – CPU and I/O statistics
Process Management - ps aux – List running processes
- kill – Terminate a process
- pkill -9 – Kill process by name
- nohup & – Run command in the background
- jobs – List background processes
- fg %1 – Bring job to foreground
Networking - ip a – Show IP addresses
- netstat -tulnp – Show open ports
- ss -tulnp – Alternative to netstat
- ping – Check connectivity
- curl -I – Get HTTP headers
- wget – Download file
- traceroute – Trace network path
User & Permission Management - whoami – Show current user
- id – Show user ID and groups
- sudo su – – Switch user
- chmod 755 – Change file permissions
- chown user:group – Change file owner
File & Directory Operations - ls -lah – List files with details
- cp -r – Copy directories
- mv – Move or rename files
- rm -rf – Remove directory
- find /path -name “file.txt” – Search file by name
- grep “pattern” file.txt – Search inside files
Package Management - apt update && apt upgrade -y – Update (Debian/Ubuntu)
- yum update -y – Update (RHEL/CentOS)
- dnf install – Install package (Fedora)
Log Management - tail -f /var/log/syslog – View live logs
- journalctl -xe – View system logs
SSH & Remote Access - ssh user@host – Connect via SSH
- scp file user@host:/path – Copy file via SSH
- rsync -avz – Sync files
Practical Challenges & Solutions
Challenge 1: System Monitoring & Optimization
Q1: How do you find the process consuming the most CPU?
Use top or htop and check the column with the highest CPU usage.
Q2: How do you check free memory on a system?
Run free -m to see available and used memory.
Q3: How do you determine which directory is consuming the most space?
Use du -sh * | sort -hr to sort directories by size.
Challenge 2: Process & Job Management
Q1: How do you list all running processes?
Solution: Run ps aux to view all active processes.
Q2: How do you kill a process by its name?
Solution: Use pkill -9 to terminate it.
Q3: How do you bring a background job to the foreground?
Solution: Use fg % to move the job to the foreground.
Challenge 3: Networking & Connectivity
Q1: How do you find the system’s IP address?
Solution: Run ip a to display network interfaces and their IP addresses.
Q2: How do you check which ports are open?
Solution: Use netstat -tulnp or ss -tulnp to list listening ports.
Q3: How do you download a file from the internet?
Solution: Use wget or curl -O .
Challenge 4: User & File Permissions
Q1: How do you create a new user and switch to it?
Run sudo useradd and then su – .
Q2: How do you give a file read, write, and execute permissions for its owner?
Use chmod 700 to set the correct permissions.
Q3: How do you change the ownership of a file?
Run chown user:group to assign a new owner.
Challenge 5: Remote Access & File Transfer
Q1: How do you connect to a remote server using SSH?
Use ssh user@host.
Q2: How do you securely transfer a file to a remote server?
Use scp user@host:/path.
Q3: How do you synchronize a local directory with a remote one?
Run rsync -avz to copy only changes.