Linux is a core skill for DevOps Engineers because cloud servers, CI/CD agents, containers, Kubernetes nodes, monitoring tools, and automation scripts commonly run on Linux. Docker Engine is installed on Linux hosts, while Kubernetes nodes run services such as the kubelet, container runtime, and kube-proxy. (Docker Documentation)
This guide covers the small set of Linux concepts and commands that provide the greatest practical and interview value.
What Is Linux?
Linux is an open-source operating-system platform. More precisely, the Linux kernel is the central component that communicates with hardware and manages CPU, memory, devices, processes, and other system resources. A Linux distribution combines this kernel with system utilities, package managers, shells, and applications. (Red Hat)
Popular Linux distributions include:
- Red Hat Enterprise Linux
- Ubuntu
- Amazon Linux
- CentOS Stream
- Fedora
- Debian
- SUSE Linux Enterprise
For DevOps roles, prioritize:
- Ubuntu: Popular for cloud servers, containers, and development.
- Amazon Linux: Common on AWS EC2.
- RHEL: Widely used in enterprise environments.
- CentOS Stream: Useful for learning the RHEL ecosystem.
Your uploaded notes also identify Linux as multi-user, multitasking, open source, secure, and resource-efficient.
Why DevOps Engineers Need Linux
A DevOps Engineer uses Linux to:
- Connect to cloud servers through SSH.
- Install and configure Jenkins, Docker, Nginx, Apache, and monitoring agents.
- Build and deploy applications.
- Manage users, groups, permissions, services, and packages.
- Troubleshoot CPU, memory, disk, networking, and application problems.
- Read logs and identify deployment failures.
- Write Shell scripts to automate repetitive tasks.
- Manage Docker hosts and Kubernetes worker nodes.
- Run Terraform, Ansible, Git, Maven, and cloud CLI commands.
AWS supports connecting to Linux EC2 instances through SSH using a username, private key, and instance address. (AWS Documentation)
1. Understand Linux Architecture
The main Linux layers are:
Hardware
The physical or virtual resources:
- CPU
- Memory
- Disk
- Network interface
- Devices
Kernel
The kernel manages:
- Processes
- Memory
- Filesystems
- Devices
- Networking
- System calls
Shell
The shell accepts commands and communicates with the operating system.
Common shells:
- Bash
- Zsh
- Sh
Applications and User Interface
Users interact with Linux through:
- Command-line interface
- Graphical interface
- Applications
- APIs and automation tools
Your Linux architecture diagram shows the relationship as:
User Interface
↓
Shell
↓
Kernel
↓
Hardware
Interview answer
What is the Linux kernel?
The Linux kernel is the core component of the operating system. It manages CPU, memory, devices, processes, filesystems, and communication between software and hardware.
2. Linux Filesystem Hierarchy
Linux uses a hierarchical filesystem beginning with /, called the root directory.
| Directory | DevOps purpose |
|---|---|
/ | Top-level directory |
/home | Regular users’ home directories |
/root | Root user’s home directory |
/etc | System and application configuration |
/var | Logs, caches, web files, and changing data |
/var/log | System and application logs |
/tmp | Temporary files |
/usr | Programs, libraries, and shared resources |
/bin | Essential user commands |
/sbin | System administration commands |
/opt | Optional third-party applications |
/boot | Kernel and bootloader files |
/proc | Runtime process and kernel information |
/dev | Device files |
/mnt | Temporary mounted filesystems |
The most important directories for DevOps work are:
/etcfor configuration/var/logfor troubleshooting/var/libfor application data/optfor installed tools/homefor user files/tmpfor temporary data
Your uploaded notes also identify /, /root, /home, /boot, /etc, /usr, /bin, and /sbin as essential directories.
3. Essential File and Directory Commands
These commands handle most daily file operations.
pwd # Show current directory
ls # List files
ls -la # Include hidden files and details
cd /var/log # Change directory
mkdir app # Create directory
mkdir -p app/config # Create nested directories
touch app.log # Create an empty file
cp file1 file2 # Copy a file
cp -r app backup/ # Copy a directory
mv old.txt new.txt # Rename a file
mv app /opt/ # Move a directory
rm file.txt # Delete a file
rm -r old-directory # Delete directory recursively
These commands appear throughout your Linux notes and command practice.
Critical safety rule
Do not run this command unless you fully understand the target:
rm -rf
rm -rf deletes recursively without confirmation. A wrong path can destroy application or system data.
Interview question
What is the difference between cp and mv?
cpcreates a copy while keeping the original.mvmoves the original file or renames it.
4. Reading and Editing Files
A DevOps Engineer constantly reads:
- Configuration files
- Pipeline files
- Deployment scripts
- Application logs
- Dockerfiles
- YAML manifests
Important commands:
cat file.txt # Display the complete file
less file.txt # Read large files page by page
head file.txt # Show first 10 lines
head -n 20 file.txt # Show first 20 lines
tail file.txt # Show last 10 lines
tail -n 100 app.log # Show last 100 lines
tail -f app.log # Follow log updates in real time
Editors:
vi file.txt
vim file.txt
nano file.txt
Your notes correctly identify cat, less, head, tail, vi, vim, and nano as fundamental file-management tools.
High-value DevOps command
tail -f /var/log/application.log
Use it while deploying an application to watch new log entries in real time.
5. Search and Text Processing
Linux troubleshooting depends heavily on searching files and filtering output.
Search inside files with grep
grep "ERROR" application.log
grep -i "failed" application.log
grep -n "timeout" application.log
grep -R "database_url" /etc/myapp/
Common options:
-i: Ignore uppercase and lowercase differences-n: Display line numbers-R: Search recursively-v: Exclude matching lines
Examples:
grep -i "error" app.log
grep -v "INFO" app.log
Find files and directories
find /var/log -type f
find /etc -type f -name "*.conf"
find /opt -type d -name "jenkins"
find /var/log -type f -mtime -1
Your command history includes practical find examples for locating files and directories across the filesystem.
Pipes and redirection
A pipe sends the output of one command to another:
ps aux | grep nginx
df -h | grep "/dev"
cat app.log | grep ERROR
Redirect output:
command > output.txt # Replace file contents
command >> output.txt # Append to file
command 2> error.log # Redirect errors
command > all.log 2>&1 # Redirect output and errors
Run the next command only when the first succeeds:
mkdir release && cd release
These features are essential for Shell scripting and CI/CD automation.
6. Users, Groups, and Root Access
Linux is a multi-user operating system. Every file and process belongs to a user and group.
Important commands:
whoami # Current user
id # User and group information
useradd developer # Create user
passwd developer # Set password
userdel -r developer # Delete user and home directory
groupadd devops # Create group
usermod -aG devops developer # Add user to group
groups developer # Display user groups
sudo command # Run command with elevated privileges
Your notes include user creation, group creation, adding users to groups, and deleting users and groups.
Root vs. sudo
- Root has unrestricted system access.
- sudo grants controlled administrative access.
- Enterprise systems should follow least privilege.
- Administrators should avoid routine work as root.
Interview question
Why is sudo preferred over directly using root?
sudoprovides controlled administrative access, supports auditing, and reduces the risk of accidental or unauthorized system changes.
7. Linux File Permissions
Linux permissions control who can read, modify, or execute a file.
The three permission types are:
r— Readw— Writex— Execute
Permissions apply to:
- Owner
- Group
- Others
View permissions:
ls -l
Example:
-rwxr-xr--
Meaning:
- Owner: read, write, execute
- Group: read and execute
- Others: read only
Permission numbers
| Permission | Value |
|---|---|
| Read | 4 |
| Write | 2 |
| Execute | 1 |
Common examples:
chmod 644 config.txt
chmod 755 deploy.sh
chmod 600 private-key.pem
chmod +x deploy.sh
Typical meaning:
644: Owner can edit; others can read.755: Owner can edit and execute; others can read and execute.600: Only the owner can read and write.
Change ownership:
chown user file.txt
chown user:group file.txt
chown -R jenkins:jenkins /opt/app
chgrp devops deploy.sh
Your uploaded material identifies chmod, chown, and chgrp as the main permission and ownership commands.
Common mistake
chmod 777 file
Avoid 777 unless there is an exceptional and justified requirement. It gives every user full access.
Interview answer
What is the difference between chmod and chown?
chmodchanges permissions.chownchanges the owner or group associated with a file.
8. Package Management
Package managers install, update, and remove software.
RHEL, Amazon Linux, Fedora
Modern systems commonly use dnf:
sudo dnf install nginx -y
sudo dnf update nginx -y
sudo dnf remove nginx -y
sudo dnf list installed
Some environments still support yum:
sudo yum install httpd -y
sudo yum update httpd -y
sudo yum remove httpd -y
Ubuntu and Debian
sudo apt update
sudo apt install nginx -y
sudo apt upgrade
sudo apt remove nginx
Your command practice includes installing Apache, Docker, Java, Python, and Jenkins using yum.
DevOps principle
Do not blindly install packages from unknown websites. Prefer:
- Official distribution repositories
- Vendor-supported repositories
- Verified GPG keys
- Version-controlled installation scripts
Docker’s official documentation recommends installing Docker Engine through its official package repository for easier installation and upgrades. (Docker Documentation)
9. Service Management with systemd
Modern Linux distributions commonly use systemd and systemctl.
systemctl status nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl enable nginx
sudo systemctl disable nginx
sudo systemctl enable --now nginx
Important differences:
start: Start now.stop: Stop now.restart: Stop and start again.reload: Reload configuration without a full restart when supported.enable: Start automatically during boot.disable: Do not start automatically during boot.
Your older notes include service and chkconfig. These may still work on some systems, but systemctl is the preferred command on modern systemd-based Linux distributions.
Practical deployment validation
sudo nginx -t
sudo systemctl reload nginx
systemctl status nginx
Always validate configuration before restarting a production service.
10. Logs and Troubleshooting
Logs are one of the first places a DevOps Engineer checks after a deployment failure.
Common locations:
/var/log/messages
/var/log/syslog
/var/log/secure
/var/log/auth.log
/var/log/nginx/
/var/log/httpd/
Systemd logs:
journalctl
journalctl -u nginx
journalctl -u nginx --since "30 minutes ago"
journalctl -u jenkins -f
journalctl -p err
Application logs:
tail -n 100 /var/log/nginx/error.log
tail -f /var/log/jenkins/jenkins.log
grep -i "failed" /var/log/application.log
Practical troubleshooting sequence
When an application is unavailable:
systemctl status myapp
journalctl -u myapp --since "10 minutes ago"
ps aux | grep myapp
ss -tulpn
curl -I http://localhost:8080
df -h
free -h
This checks:
- Service status
- Service logs
- Running process
- Listening port
- Local application response
- Disk capacity
- Memory availability
11. Process Management
A process is a running program.
Important commands:
ps aux
ps -ef
top
htop
pgrep nginx
pgrep -af java
kill PID
kill -15 PID
kill -9 PID
Signals:
SIGTERMorkill -15: Requests a graceful shutdown.SIGKILLorkill -9: Immediately terminates the process.
Best practice
Use kill -15 first. Use kill -9 only when the process does not stop gracefully.
Run a process in the background:
command &
Check background jobs:
jobs
Keep a process running after logout:
nohup command > app.log 2>&1 &
12. CPU, Memory, and Disk Monitoring
CPU and processes
top
uptime
ps aux --sort=-%cpu | head
nproc
lscpu
Memory
free -h
cat /proc/meminfo
ps aux --sort=-%mem | head
Disk
df -h
du -sh /var/log/*
lsblk
mount
Your notes include df -h, /proc/meminfo, and /proc/cpuinfo for system-resource checks.
Important distinction
df -h: Shows filesystem capacity and available space.du -sh: Shows how much space a directory or file consumes.
Common production issue
An application may stop because /var or / becomes full due to growing logs.
Investigation:
df -h
du -sh /var/log/*
find /var/log -type f -size +500M
13. Linux Networking Commands
Modern Linux networking commands:
hostname
hostnamectl
ip addr
ip route
ss -tulpn
ping example.com
curl -I https://example.com
wget URL
dig example.com
nslookup example.com
traceroute example.com
Use cases:
ip addr: Check IP addresses.ip route: Check routing.ss -tulpn: Check listening ports.curl: Test HTTP or API endpoints.dig: Test DNS resolution.ping: Test basic connectivity.
Your notes use ifconfig, but ip addr is generally preferred on modern Linux systems.
Check whether an application is listening
ss -tulpn | grep 8080
Test the local application
curl -I http://localhost:8080
Interview question
A website is unavailable. What do you check?
I check DNS resolution, network connectivity, security rules, the listening port, service status, application logs, reverse-proxy configuration, CPU, memory, and disk utilization.
14. SSH and Cloud Server Access
SSH provides secure remote access to Linux servers.
AWS EC2 example:
chmod 400 my-key.pem
ssh -i my-key.pem ec2-user@PUBLIC_IP
Ubuntu EC2 example:
ssh -i my-key.pem ubuntu@PUBLIC_IP
Typical usernames:
- Amazon Linux:
ec2-user - Ubuntu:
ubuntu - RHEL:
ec2-useror a configured user
AWS documents SSH access using the private key, username, and public DNS name or IP address. (AWS Documentation)
Copy a file to a server:
scp -i my-key.pem app.jar ec2-user@PUBLIC_IP:/opt/app/
Copy a directory:
scp -r -i my-key.pem website/ ec2-user@PUBLIC_IP:/var/www/
Security best practices
- Never share private keys.
- Use restrictive key permissions.
- Avoid direct root login.
- Restrict SSH access by source IP.
- Prefer short-lived or centrally managed access.
- Back up SSH configuration before editing.
- Validate configuration before restarting SSH.
15. Archives, Compression, and Links
Tar and gzip
Create an archive:
tar -cvf backup.tar app/
Extract it:
tar -xvf backup.tar
Create a compressed archive:
tar -czvf backup.tar.gz app/
Extract it:
tar -xzvf backup.tar.gz
Your command history contains these same archive and compression operations.
Soft link
ln -s /opt/app/current app-link
A soft link:
- Points to another path.
- Can cross filesystems.
- Breaks when the original target is deleted.
Hard link
ln file.txt hard-link.txt
A hard link:
- Points to the same inode.
- Normally cannot cross filesystems.
- Still accesses the data if the original filename is removed.
Interview question
What is the difference between soft and hard links?
A soft link stores a path to another file and can become broken. A hard link points to the same inode and continues working when the original filename is removed.
16. Shell Scripting for DevOps Automation
Shell scripting automates repetitive Linux tasks such as:
- Installing packages
- Deploying applications
- Checking service health
- Rotating logs
- Creating users
- Backing up files
- Running scheduled jobs
Example:
#!/bin/bash
SERVICE="nginx"
if systemctl is-active --quiet "$SERVICE"; then
echo "$SERVICE is running"
else
echo "$SERVICE is stopped"
sudo systemctl start "$SERVICE"
fi
Important scripting concepts:
- Variables
- Conditions
- Loops
- Functions
- Exit codes
- Command-line arguments
- Standard output and errors
Check the previous command:
echo $?
0: Success- Non-zero: Failure
CI/CD pipelines rely on exit codes to decide whether a stage passed or failed.
Use strict error handling:
#!/bin/bash
set -euo pipefail
This makes many automation scripts safer by stopping on errors, undefined variables, or failed pipeline commands.
17. Linux in the DevOps Lifecycle
A typical workflow looks like this:
Developer commits code
↓
GitHub stores source code
↓
Jenkins or GitHub Actions runs on Linux
↓
Maven or another tool builds the application
↓
Docker creates the container image
↓
Kubernetes deploys it to Linux nodes
↓
Prometheus and Grafana monitor it
↓
Linux commands and logs troubleshoot failures
Docker Engine supports Linux installation, while Kubernetes schedules containerized workloads onto nodes that provide services required to run Pods. (Docker Documentation)
18. Practical Linux Troubleshooting Scenarios
Scenario 1: Service is down
systemctl status nginx
journalctl -u nginx --since "20 minutes ago"
sudo nginx -t
sudo systemctl restart nginx
Scenario 2: Application port is unavailable
ss -tulpn | grep 8080
ps aux | grep java
curl -I http://localhost:8080
Scenario 3: Server is slow
uptime
top
free -h
df -h
ps aux --sort=-%cpu | head
ps aux --sort=-%mem | head
Scenario 4: Disk is full
df -h
du -sh /var/*
du -sh /var/log/*
find /var/log -type f -size +500M
Scenario 5: Permission denied
ls -l deploy.sh
id
namei -l /opt/app/deploy.sh
chmod +x deploy.sh
chown user:group deploy.sh
Scenario 6: DNS or network failure
ip addr
ip route
ping 8.8.8.8
dig example.com
curl -v https://example.com
19. High-Value Linux Interview Questions
What is Linux?
Linux is an open-source operating-system platform commonly used for servers, cloud infrastructure, automation, containers, and enterprise applications.
Why is Linux important for DevOps?
DevOps tools, cloud workloads, CI/CD agents, container hosts, and Kubernetes nodes commonly operate on Linux. It provides strong automation, scripting, networking, security, and troubleshooting capabilities.
What is the root directory?
/ is the top-level directory in the Linux filesystem.
What is the difference between /root and /home?
/root is the root user’s home directory. /home contains home directories for regular users.
How do you check a service?
systemctl status service-name
How do you check logs?
journalctl -u service-name
tail -f /var/log/application.log
How do you check disk usage?
df -h
du -sh directory
How do you check memory?
free -h
How do you check listening ports?
ss -tulpn
How do you find a file?
find /path -type f -name "filename"
What is a pipe?
A pipe, |, sends the output of one command as input to another command.
What does permission 755 mean?
The owner has read, write, and execute permissions. The group and others have read and execute permissions.
What is the difference between kill -15 and kill -9?
kill -15 requests a graceful shutdown. kill -9 immediately forces termination.
How would you troubleshoot an unavailable application?
Check service status, logs, processes, listening ports, local endpoint response, DNS, routing, firewall rules, CPU, memory, and disk.
20. Best Linux Learning Strategy for DevOps
Do not try to memorize hundreds of commands.
Focus on these areas:
- Files and directories
- Permissions and ownership
- Users and groups
- Packages and services
- Processes and resource monitoring
- Logs and troubleshooting
- Networking and SSH
- Pipes and redirection
- Shell scripting
- Docker and Kubernetes host operations
Practice on an Ubuntu or Amazon Linux EC2 instance.
Recommended practical project
Build a Linux web server:
- Launch a Linux EC2 instance.
- Connect using SSH.
- Create a non-root administrative user.
- Install Nginx or Apache.
- Enable and start the service.
- Deploy a basic website.
- Configure file ownership and permissions.
- Test the website with
curl. - Review service and access logs.
- Write a health-check script.
- Schedule the script using cron.
- Document troubleshooting commands.
This single project covers most Linux skills expected from a junior or mid-level DevOps Engineer.
Common Mistakes to Avoid
- Using
chmod 777as a quick fix. - Running every command as root.
- Executing
rm -rfwithout verifying the path. - Using
kill -9before attempting graceful termination. - Restarting a service before checking logs.
- Editing SSH configuration without keeping another session open.
- Ignoring disk usage and log growth.
- Installing packages from untrusted sources.
- Memorizing commands without practicing troubleshooting.
- Learning obsolete commands only, such as relying entirely on
ifconfig,service, andchkconfig.
Key Takeaways
Linux knowledge for DevOps is not about memorizing every command. It is about confidently performing five responsibilities:
- Manage servers.
- Automate repetitive work.
- Secure users and files.
- Deploy and operate applications.
- Troubleshoot failures using commands, logs, and system metrics.
Master the command line, permissions, systemd, processes, networking, logs, SSH, and basic Shell scripting before moving deeply into Docker, Kubernetes, Jenkins, Ansible, or cloud operations.