DEV Community

Cover image for Essential Linux Commands for DevOps Engineers
Megha Shivhare
Megha Shivhare

Posted on

Essential Linux Commands for DevOps Engineers

As a DevOps engineer, mastering Linux commands is fundamental for managing infrastructure, automating tasks, and ensuring seamless deployments. This blog highlights critical Linux command categories that every DevOps professional should know.


1. Process Management

Process management is vital for controlling and monitoring applications running on Linux systems. Here are essential commands:

Key Commands and Their Usage:

List processes:

ps aux        # Shows all running processes
ps -ef        # Alternative format for process listing
ps -u username # Processes for a specific user
Enter fullscreen mode Exit fullscreen mode

Process monitoring:

top           # Interactive process viewer
htop          # Enhanced version with color coding and mouse support
Enter fullscreen mode Exit fullscreen mode

Process control:

kill PID      # Send SIGTERM to terminate a process
kill -9 PID   # Forcefully terminate a process
killall name  # Kill all processes by name
Enter fullscreen mode Exit fullscreen mode

Service management:

systemctl start service   # Start a service
systemctl stop service    # Stop a service
systemctl restart service # Restart a service
Enter fullscreen mode Exit fullscreen mode

Process priority management:

nice -n 10 command        # Start command with lower priority
renice -n 10 -p PID       # Adjust priority of a running process
Enter fullscreen mode Exit fullscreen mode

2. File System Management

Linux filesystems are organized in a tree structure. Managing files and directories is integral to system administration.

Key Commands and Their Usage:

File permissions:

chmod 755 file            # rwx for owner, rx for others
chown user:group file     # Change ownership
Enter fullscreen mode Exit fullscreen mode

File searching:

find / -type f -name "*.log"   # Find all log files
find / -mtime -7               # Files modified in the last 7 days
Enter fullscreen mode Exit fullscreen mode

Disk usage:

du -sh *                     # Size of directory contents
df -h                        # Filesystem usage
Enter fullscreen mode Exit fullscreen mode

3. Network Management

Network configuration and troubleshooting are key DevOps skills.

Key Commands and Their Usage:

Network connectivity:

ip addr      # Show IP addresses
ping -c 4 host # Test connectivity with 4 packets
Enter fullscreen mode Exit fullscreen mode

Port monitoring:

netstat -tulpn     # Show listening ports and processes
ss -tunlp          # Modern alternative to netstat
Enter fullscreen mode Exit fullscreen mode

Network debugging:

tcpdump -i eth0    # Capture packets on a network interface
nmap localhost     # Scan open ports
Enter fullscreen mode Exit fullscreen mode

4. System Monitoring

Monitoring system performance ensures reliable operations.

Key Commands and Their Usage:

Resource monitoring:

free -m            # Display memory usage in MB
vmstat 1           # Virtual memory stats updated every second
Enter fullscreen mode Exit fullscreen mode

Performance analysis:

perf top           # CPU performance analysis
strace command     # Trace system calls
Enter fullscreen mode Exit fullscreen mode


5. Log Management

Logs are essential for debugging and auditing system activities.

Key Commands and Their Usage:

System logs:

journalctl -f                # Follow system logs
journalctl -u service        # View service-specific logs
tail -f /var/log/syslog      # Follow the system log
Enter fullscreen mode Exit fullscreen mode

Log analysis:

grep -r "error" /var/log/    # Search for errors in logs
awk '/pattern/ {print $1,$2}' logfile # Extract specific fields
Enter fullscreen mode Exit fullscreen mode


6. Package Management

Managing software packages efficiently is crucial for system updates and deployments.

Key Commands and Their Usage:

For RHEL/CentOS:

yum update -y             # Update all packages
yum install package       # Install a specific package
Enter fullscreen mode Exit fullscreen mode

For Ubuntu/Debian:

apt update && apt upgrade # Update system
apt install package       # Install a package
Enter fullscreen mode Exit fullscreen mode


7. Security Management

Securing systems involves managing user access, monitoring, and hardening configurations.

Key Commands and Their Usage:

User management:

useradd -m username    # Create a user with a home directory
passwd username        # Set a password for the user
Enter fullscreen mode Exit fullscreen mode

Security monitoring:

last                   # Show last logins
fail2ban-client status # Display banned IPs
Enter fullscreen mode Exit fullscreen mode

Conclusion

Mastering these Linux commands will enhance your efficiency as a DevOps engineer. They are essential for automation, troubleshooting, and maintaining secure, high-performing systems.

Top comments (8)

Collapse
 
jessilyneh profile image
Jessilyneh

very useful content!

Collapse
 
megha_shivhare_5038dc1047 profile image
Megha Shivhare

glad it helped!

Collapse
 
sherif_san profile image
Sherif sani

Thanks for sharing 🙏

Collapse
 
shiva_shanmugam profile image
Shiva Shanmugam

Very useful one !

Collapse
 
juhi_sayyed_5d038f5987c0f profile image
juhi sayyed

Thanks you, @megha_shivhare_5038dc1047, for sharing this insightful information. it has been incredibly helpful in my office environment. Could you also create blog on "Log Management" as you mentioned in this post. I would love to explore more command on this topic.

Collapse
 
megha_shivhare_5038dc1047 profile image
Megha Shivhare

Thanks for the feedback, will bring a more detailed blog on log management soon.

Collapse
 
shotvpro profile image
Ankit Jain

Thanks for the informations! very helpful.

Collapse
 
megha_shivhare_5038dc1047 profile image
Megha Shivhare

Thank you!

Some comments may only be visible to logged-in visitors. Sign in to view all comments.