Important Linux Commands for DevOps

๐Ÿง  Introduction

In the world of DevOps, Linux is everywhereโ€”from development environments and CI/CD runners to production servers and cloud infrastructure. Whether you’re deploying containers, configuring CI pipelines, or managing cloud instances, chances are you’re doing it on a Linux-based system.

For DevOps engineers, having a strong grasp of Linux commands is not just helpfulโ€”it’s essential. These commands allow you to troubleshoot issues quickly, automate tasks efficiently, and maintain systems effectively.

In this post, weโ€™ll explore a curated list of essential Linux commands every DevOps engineer should know, categorized by their use case and practical value in real-world DevOps workflows.

๐Ÿงฐ System Information Commands

Before making any changes to a server or container, itโ€™s important to know the system youโ€™re working with. These commands help you gather key information about your Linux system:

CommandDescription
uname -aDisplays system architecture, kernel version, and OS info.
hostnameShows the systemโ€™s hostname. Useful in multi-node clusters.
uptimeTells you how long the system has been running.
top / htopLive display of running processes and resource usage.

๐Ÿ”ง Example Use Case:

You log into a production EC2 instance to debug performance issues. Running top quickly shows that memory usage is maxed out due to a misconfigured process. You can act immediately to mitigate the impact.

๐Ÿ“ File and Directory Commands

Navigating the file system is a basic yet vital part of any DevOps workflow. Whether you’re modifying config files, reading logs, or moving scripts around, these commands are your bread and butter:

CommandDescription
lsLists files and directories. Use ls -l for details.
cdChanges the current working directory.
pwdPrints the full path of the current directory.
mkdirCreates a new directory.
rmDeletes files (rm -rf deletes directories recursively).
cpCopies files and directories.
mvMoves or renames files/directories.
findSearches files by name, type, size, etc.
treeVisual representation of directory structure (install separately).

๐Ÿ”ง Example Use Case:

While setting up a deployment script, you use find /var/www -name "*.log" to locate and clean up leftover log files from a previous release.

๐Ÿ” File Permissions and Ownership

File permissions are crucial for system security and stability, especially when working in multi-user environments or deploying scripts to production.

CommandDescription
chmodChanges file permissions (e.g., chmod 755 file.sh).
chownChanges file ownership (e.g., chown user:group file).
chgrpChanges group ownership.
umaskSets default permission for new files.

๐Ÿ”ง Example Use Case:

After deploying a new script via a CI pipeline, you use chmod +x deploy.sh to make it executable, and chown root:root deploy.sh to assign the proper owner.

๐Ÿ“ฆ Package Management

Different Linux distributions use different package managers. Knowing how to install, update, or remove software is key for server provisioning.

For Debian/Ubuntu:

CommandDescription
apt updateUpdates package lists.
apt upgradeInstalls latest versions of packages.
apt install nginxInstalls a package.
apt remove nginxRemoves a package.

For RHEL/CentOS:

CommandDescription
yum install nginx / dnf install nginxInstalls packages.
yum updateUpdates all packages.
rpm -qaLists all installed RPM packages.

๐Ÿ”ง Example Use Case:

During provisioning, your script installs Docker and Git using apt install -y docker.io git, ensuring all build agents are properly configured.

๐Ÿ“ Text Processing Commands

DevOps work involves a lot of log reading, config editing, and data processing. These tools help extract valuable insights from text:

CommandDescription
cat, less, moreDisplay file contents.
head, tailShow beginning/end of files.
grepSearch for patterns in files.
awk, sedStream editing and text transformation.
cut, sort, uniqColumn filtering, sorting, deduplication.

๐Ÿ”ง Example Use Case:

You monitor deployment logs with tail -f deploy.log | grep error to catch any real-time failures in your pipeline.

๐ŸŒ Networking Commands

Diagnosing network issues is a day-to-day task in DevOps. These commands help you test connectivity, DNS, ports, and more:

CommandDescription
ping google.comChecks basic connectivity.
curl / wgetSends HTTP requests.
netstat / ssShows active ports and connections.
tracerouteTracks route to a host.
dig, nslookupDNS lookup tools.

๐Ÿ”ง Example Use Case:

While deploying an app, curl http://localhost:3000/health helps validate that your service is up and running correctly.

โš™๏ธ Process and Service Management

Managing background services, checking process health, and restarting daemons are critical for uptime and reliability.

CommandDescription
ps auxLists running processes.
kill PIDTerminates a process.
killall nginxKills all processes with name.
nice / reniceSets process priority.
systemctlManages services (start, stop, restart).
journalctlViews system logs (e.g., journalctl -u nginx).

๐Ÿ”ง Example Use Case:

After updating a config, use systemctl restart nginx and monitor logs via journalctl -u nginx -f.

๐Ÿงฎ Disk and Memory Usage

Running out of disk or memory can crash systems and pipelines. These commands help you keep an eye on resource consumption:

CommandDescription
df -hShows disk space usage in human-readable format.
du -sh *Shows size of each item in current directory.
free -mDisplays memory usage.
vmstatReports system performance.
iostatShows CPU and disk I/O (requires sysstat).

๐Ÿ”ง Example Use Case:

Your CI runner is failing builds. You find with df -h that the disk is full and clear old Docker images to free space.

๐Ÿ“œ Archiving and Compression

Useful for backups, file transfers, and packaging code, these commands help you archive and compress data effectively:

CommandDescription
tar -czvf backup.tar.gz folder/Compress a directory.
tar -xzvf backup.tar.gzExtract an archive.
zip -r archive.zip folder/Create a zip file.
unzip archive.zipUnpack a zip file.

๐Ÿ”ง Example Use Case:

Before deploying a release, you archive the build folder with tar -czvf release.tar.gz dist/ for backup.

๐Ÿ”„ Scripting and Automation Basics

Bash scripting is essential for automating tasks, especially in CI/CD pipelines or cron jobs.

Basic Elements:

#!/bin/bash

# Variables
ENV="prod"

# Conditional
if [ "$ENV" == "prod" ]; then
  echo "Deploying to production"
fi

# Loop
for i in {1..3}; do
  echo "Running test $i"
done

# Function
backup() {
  tar -czf backup.tar.gz /var/www
}

Scheduling with Cron:

crontab -e
# Run backup at 2AM every day
0 2 * * * /home/ubuntu/backup.sh

๐Ÿ”ง Example Use Case:

You schedule automated backups with a Bash script and cron job to ensure daily snapshots of your app data.


๐Ÿงช Bonus: DevOps Tools Installed via Linux

Linux is the preferred platform for installing and running most DevOps tools:

ToolCommand
Gitsudo apt install git
Dockersudo apt install docker.io
Kubernetes CLIcurl -LO https://dl.k8s.io/release/... && chmod +x kubectl
Terraformwget https://... && unzip terraform.zip

These tools become part of your toolchain and are often automated via scripts during infrastructure setup.

๐Ÿง  Conclusion

Linux commands are the foundation of every DevOps professionalโ€™s toolkit. Whether youโ€™re automating deployments, debugging servers, or managing cloud instances, a strong command-line fluency helps you move faster and work smarter.

๐Ÿ‘‰ Practice daily, incorporate them into your scripts, and consider creating aliases or functions for repetitive tasks.

If you found this post helpful:

  • โœ… Subscribe to my YouTube Channel for tutorials on AWS, Linux, and DevOps.
  • ๐Ÿ’ฌ Comment below your favorite Linux command or share one that helped you in production.
  • ๐Ÿ”” Follow me on LinkedIn for more tips and updates.

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply