There are no items in your cart
Add More
Add More
| Item Details | Price | ||
|---|---|---|---|
Top 50 Linux Commands Every DevOps Engineer Must Know
The Complete Hands-On Terminal Reference Guide for System Administration, Troubleshooting, Networking, Automation & Cloud Operations
Linux is the operating system backbone of modern cloud infrastructure. Over 90% of cloud servers on AWS, Azure, GCP, and Kubernetes run Linux distributions (Ubuntu, RHEL, Amazon Linux, Debian). Whether you are troubleshooting container crashes, inspecting system resources, configuring network firewalls, or writing CI/CD automation scripts, mastering CLI utilities is an essential core skill for every DevOps and SRE professional.
Before deploying applications or debugging resource bottlenecks, you must inspect hardware specs, kernel versions, and storage utilization.
uname — Kernel & OS Architecture InformationPrints system details, kernel release, and hardware architecture.
# Display all kernel and OS system info
uname -a
# Output example:
# Linux devops-server 5.15.0-101-generic #111-Ubuntu SMP x86_64 GNU/Linux
hostname / hostnamectl — Host Network IdentificationInspect or modify the system's hostname and view IP address bindings.
# Show detailed system host and OS chassis info
hostnamectl
# Display internal IP address associated with the host
hostname -I
uptime — Server Running Time & Load AveragesDisplays how long the server has been running, logged-in users, and system load averages over 1, 5, and 15 minutes.
# Pretty print system uptime duration
uptime -p
# Standard output showing load averages:
# 14:32:01 up 45 days, 3:12, 2 users, load average: 0.15, 0.22, 0.18
df — Disk Space Filesystem ConsumptionInspects total, used, and available storage space across mounted file systems.
# Human-readable format showing filesystem type (-hT)
df -hT
du — Directory & File Space EstimationCalculates disk space consumed by specific folders and identifies space-hogging logs.
# Find top 10 largest directories in /var/log
du -sh /var/log/* | sort -hr | head -n 10
free — Memory (RAM & Swap) InspectionDisplays total, used, free, and available physical memory and swap space.
# Display memory stats in Gigabytes/Megabytes with totals (-h -t)
free -h -t
lscpu & lsblk — CPU Cores & Block Storage DevicesLists CPU architecture, core counts, threads, and attached block devices (EBS volumes/disks).
# View CPU details
lscpu
# View attached disk partitions and filesystems
lsblk -f
Navigating directory trees, creating nested directories, and archiving logs are fundamental daily tasks.
ls — Directory Listing & Metadata InspectionLists files and directories with permissions, owner, size, and modification timestamps.
# List all files including hidden ones (-a), long format (-l), sorted by size (-S), human readable (-h)
ls -laSh /var/log
find — Advanced File Search EngineRecursively searches directories based on file name, modification time, size, or permissions.
# Find all .log files in /var/log modified in the last 7 days exceeding 50MB
find /var/log -type f -name "*.log" -mtime -7 -size +50M
which & whereis — Locate Executable Binary PathsFinds the absolute file path of CLI executables and binaries.
# Find binary path of docker and kubectl
which docker
whereis kubectl
mkdir — Create Directory TreesCreates single or nested directory hierarchies in a single command.
# Create nested directory tree with parent folders (-p)
mkdir -p /opt/app/{bin,conf,logs,data}
rm — Remove Files & DirectoriesDeletes files or directories recursively and forcefully.
# Safely remove temporary build directory recursively
rm -rf /tmp/build_cache/
cp & mv — Copy & Move/Rename OperationsCopies or moves files and folders while preserving mode, ownership, and timestamps.
# Copy directory recursively preserving attributes (-a)
cp -a /etc/nginx /etc/nginx_backup_$(date +%F)
# Rename file
mv config.tmp config.env
ln — Create Symbolic & Hard LinksCreates shortcuts (symlinks) pointing to files or directories across the filesystem.
# Create symbolic link for Nginx site configuration
ln -s /etc/nginx/sites-available/app.conf /etc/nginx/sites-enabled/app.conf
tar — Archive & Compress FilesPacks multiple files into a single compressed .tar.gz archive or extracts them.
# Create compressed archive
tar -czvf app_logs.tar.gz /var/log/app/
# Extract archive to target folder
tar -xzvf app_logs.tar.gz -C /opt/logs/
Log inspection and text processing are central to troubleshooting production outages and auditing API traffic.
grep — Regex Text SearchSearches text patterns in files or command outputs using regular expressions.
# Search for ERROR or CRITICAL case-insensitively in log files
grep -i -E "error|critical" /var/log/syslog
awk — Pattern Scanning & Column ExtractionA powerful data extraction tool for parsing structured columns in web logs and CSV files.
# Extract Client IP (column 1) and HTTP Status Code (column 9) from Nginx access log
awk '{print $1, $9}' /var/log/nginx/access.log | head -n 10
sed — Stream Editor for In-Place ReplacementPerforms text search, find-and-replace, and line filtering in automated scripts.
# Replace DB_HOST value in-place (-i) inside configuration file
sed -i 's/DB_HOST=localhost/DB_HOST=10.0.1.50/g' .env
head & tail — Inspect File Margins & Live Log StreamingReads the first or last lines of a file, or streams live file appends in real time.
# Stream live log appends continuously (-f) showing last 50 lines
tail -f -n 50 /var/log/app.log
cat & tac — Concatenate & Print ContentReads and displays entire file contents in forward (cat) or reverse (tac) line order.
# Print OS distribution release version
cat /etc/os-release
less — Paginated Log ViewerOpens large multi-gigabyte log files without loading the full file into system RAM.
# Open log file and jump directly to the bottom (+G)
less +G /var/log/production.log
wc — Word, Line & Character CounterCounts total lines, words, or bytes in text files or piped outputs.
# Count total lines of error occurrences in access log
grep "500" /var/log/nginx/access.log | wc -l
sort & uniq — Duplicate Filtering & Frequency RankingSorts text lines and counts unique occurrences (ideal for top IP analysis).
# Find top 5 IP addresses requesting your web server
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head -n 5
cut & tr — Field Extraction & Character TranslationSplits text by delimiter or translates characters (e.g. converting lowercase to uppercase).
# Extract system usernames from /etc/passwd using ':' as delimiter
cut -d':' -f1 /etc/passwd
Managing active processes, terminating hung services, and monitoring CPU/RAM bottlenecks.
ps — Process Status SnapshotDisplays a snapshot of running processes, user ownership, CPU/RAM usage, and PIDs.
# List all running processes formatted with full command paths
ps aux | grep java
top & htop — Real-Time Task ManagerProvides a dynamic, interactive dashboard of system load, processes, memory, and CPU usage.
# Non-interactive top batch mode for scripts (-b -n 1)
top -b -n 1 | head -n 20
# Launch interactive htop (if installed)
htop
kill, pkill & killall — Process TerminationSends signals (e.g. SIGTERM -15, SIGKILL -9) to stop running processes by PID or process name.
# Force kill process by PID
kill -9 12345
# Kill process by name pattern
pkill -f uvicorn
nice & renice — Process Priority TuningAdjusts CPU scheduling priority (niceness value from -20 highest to 19 lowest).
# Increase CPU priority for PID 5678 (higher priority)
renice -n -10 -p 5678
nohup & & — Background Execution Across HangupsExecutes commands in the background that persist even if SSH sessions disconnect.
# Run python app in background immune to hangups
nohup python3 app.py > app.log 2>&1 &
jobs, fg & bg — Job ControlLists suspended background jobs and shifts tasks between foreground and background.
# List active background shell jobs
jobs -l
# Bring job 1 to foreground
fg %1
systemctl — Systemd Service ManagerControls system services, daemon reloads, and boot initialization scripts.
# Enable and start Docker service
sudo systemctl enable --now docker
# Check status of Nginx service
systemctl status nginx
Testing network connectivity, checking open listening ports, and inspecting HTTP API endpoints.
ping — Network Connectivity ICMP TestTests network reachability to remote hosts via ICMP Echo Request packets.
# Send 4 ICMP echo packets to test connection
ping -c 4 google.com
curl — HTTP & REST API Transfer UtilityTransfers data over HTTP, HTTPS, FTP, and REST APIs with custom headers and payloads.
# Send HTTP POST request with JSON body and verbose headers
curl -iv -X POST http://localhost:8000/api/v1/predict \
-H "Content-Type: application/json" \
-d '{"experience": 5, "current_lpa": 8}'
wget — Non-Interactive File DownloaderDownloads packages and files directly from HTTP/HTTPS URLs with resume support.
# Download file with resume capability (-c)
wget -c https://releases.hashicorp.com/terraform/1.5.0/terraform_1.5.0_linux_amd64.zip
ss & netstat — Socket & Port Listening AuditDisplays active TCP/UDP listening sockets and connected network endpoints.
# Show listening TCP/UDP ports (-tuln) with process names (-p)
sudo ss -tulnp
lsof — List Open Files & Port OwnersIdentifies which processes have opened specific files, devices, or network ports.
# Find process listening on port 8080
sudo lsof -i :8080
dig & nslookup — DNS Lookup & Domain ResolutionQueries DNS name servers for A records, CNAMEs, MX records, and propagation status.
# Query A record of domain name
dig +short A clouddevopshub.com
traceroute — Packet Network Hop Path TracerTraces the network path and router hops packets take to reach a destination address.
# Trace hop route to DNS server
traceroute 8.8.8.8
ip — Network Interface & Routing Table ManagerModern replacement for ifconfig to manage IP addresses, interfaces, and routes.
# Show network interface IP addresses
ip addr show
# Show default gateway routing table
ip route
nc (Netcat) — Swiss Army Knife for Ports & ConnectionsReads and writes data across network connections, useful for port connectivity testing.
# Test if remote database port 3306 is open with 3s timeout
nc -zvw3 10.0.1.50 3306
Managing file modes, user groups, and SSH remote authentication.
chmod — File Permission ModificationChanges file read (4), write (2), execute (1) access rights for Owner, Group, and Others.
# Grant owner read/write/execute, group & others read/execute
chmod 755 deploy.sh
# Secure private SSH key file (read-only by owner)
chmod 600 id_rsa
chown & chgrp — File Ownership AssignmentChanges user owner and group owner of files or directory trees.
# Recursively change ownership of /var/lib/jenkins to user jenkins and group jenkins
sudo chown -R jenkins:jenkins /var/lib/jenkins
useradd & usermod — User Account & Group ManagementCreates new system users and updates group memberships.
# Add jenkins user to docker group
sudo usermod -aG docker jenkins
sudo & su — Superuser Privilege ExecutionExecutes commands with root privileges or switches shell user context.
# Run psql prompt as postgres service user
sudo -u postgres psql
ssh, scp & rsync — Secure Remote Access & File SyncConnects securely to remote servers, copies files, and synchronizes directory trees incrementally.
# SSH using private key identity file
ssh -i key.pem ubuntu@54.210.12.34
# Fast incremental directory synchronization with compression (-z) & progress (-P)
rsync -avzP -e "ssh -i key.pem" /local/app/ ubuntu@54.210.12.34:/opt/app/
Installing software dependencies, scheduling background cron tasks, and auditing Systemd logs.
apt / yum / dnf — Package ManagersInstalls, updates, and removes system software packages on Ubuntu/Debian or RHEL/CentOS.
# Update package list and install git and curl on Ubuntu
sudo apt update && sudo apt install -y git curl
crontab — Scheduled Cron Job ManagementSchedules periodic background tasks to run automatically at specific times or intervals.
# Edit user crontab schedule
crontab -e
# Example cron entry running backup script daily at 2:00 AM:
# 0 2 * * * /opt/scripts/db_backup.sh >/dev/null 2>&1
journalctl — Systemd Service Journal AuditorQueries and filters logs generated by Systemd services and system daemons.
# View last 100 log lines of Docker service without pagination
journalctl -u docker.service -n 100 --no-pager
alias — Custom CLI Command ShortcutsCreates short aliases for long CLI commands to boost daily terminal productivity.
# Add shortcut alias for kubectl
alias k="kubectl"
alias dps="docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'"
history — Shell Execution History AuditorLists previous commands executed in the current shell session.
# Search history for previous docker commands
history | grep "docker run"
Common real-time Linux interview and operational questions for DevOps Engineers:
Answer: CPU Utilization measures the percentage of time CPU cores are active processing tasks. Load Average (seen in uptime or top) measures the average number of processes in runnable or uninterruptible state (waiting for CPU or disk I/O) over 1, 5, and 15 minute intervals. A load average exceeding total CPU core count indicates queue bottlenecks.
Answer:
1. Run du -sh /* | sort -hr to locate large directories.
2. If du shows normal space but df shows 100% full, check for deleted files held open by active processes using lsof +L1.
3. Restart the process holding the deleted file handle to release the disk blocks.
Answer: SIGTERM (-15) requests a graceful process shutdown, allowing the application to close database connections, release locks, and cleanup temporary files. SIGKILL (-9) forcefully terminates the process immediately at the kernel level without cleanup.
Answer: rsync uses a delta-transfer algorithm to copy only modified or new files, supports automatic compression (-z), preserves file permissions and symlinks, and allows resuming interrupted transfers (-P), unlike scp which recopies everything from scratch.
Answer: On the local/client machine, run nc -zvw3 or curl -v telnet://. On the remote server itself, verify with sudo ss -tulnp | grep 3306.