Linux terminal commands illustration

Linux Commands Every DevOps Engineer Should Know

Introduction

Almost every server, container and CI runner a DevOps engineer touches is Linux. You do not need to memorise every command — you need to know the twenty or so you will use daily, how to combine them, and how to find the answer when you forget the rest.

This guide is organised by task, not alphabetically: finding your way around, reading files, managing processes and services, checking disk and memory, networking, and troubleshooting. Each command comes with a practical example and a note on when to use it. All examples use standard tools available on Ubuntu and most other distributions; where a command differs between distributions, the article says so.

How to practise: run these commands on a virtual machine, a cheap cloud instance, or inside a Docker container (docker run -it ubuntu bash). Do not practise destructive commands (rm -rf, kill -9, chmod -R) on a production system or on files you care about. The goal is fluency, and fluency comes from doing, not reading.

Navigating and Working with Files

These are the commands you will type most often. Learn them until they are automatic.

pwd                 # where am I?
ls -lah              # list files, human-readable sizes, including hidden files
cd /var/log         # change directory
cd ..               # up one level; cd ~ returns home
mkdir -p /opt/app/logs   # create nested directories
touch deploy.log    # create an empty file, or update its timestamp
cp -r app/ app-backup/   # copy a directory
mv old.log archive/      # move or rename
rm -i file.log      # delete, asking first (-i is your friend)
rm -rf /tmp/stale/  # delete a directory tree — double-check the path first

File permissions are a daily topic in DevOps, and a common source of “it worked on my machine” failures:

ls -l script.sh
chmod +x script.sh          # make a script executable
chmod 644 app.conf          # owner read/write, others read-only
chown appuser:appgroup file # change owner and group (needs sudo)

Understand the numbers: 644 means read+write for the owner, read for group and others; 755 adds execute, which directories and scripts need. A file that is not executable will fail with “permission denied” even if its contents are correct — check ls -l before assuming the script is wrong.

Finding files:

find /var/log -name "*.log" -mtime -1   # log files modified in the last day
find /opt -type f -size +100M           # files over 100 MB
which kubectl                           # where is this command?
whereis nginx

Reading Files and Searching Text

Logs are where the truth lives. Learn to read them fast.

cat app.log                 # print a whole (small) file
less app.log                # page through a large file; /error to search, q to quit
head -n 50 app.log          # first 50 lines
tail -n 100 app.log         # last 100 lines
tail -f /var/log/syslog     # follow a log live; Ctrl+C to stop

grep is the single most useful troubleshooting command in Linux. Learn it well:

grep -i "error" app.log              # case-insensitive search
grep -rn "connection refused" /var/log/   # recursive, with line numbers
grep -c "500" access.log             # count matches
grep -v "healthcheck" app.log | tail -n 50  # exclude noisy lines

Combine it with pipes to answer real questions: “How many 500 errors did we get in the last hour, and from which endpoints?”

grep " 500 " access.log | awk '{print $7}' | sort | uniq -c | sort -nr | head

That pipeline — grep to filter, awk to pick a column, sort | uniq -c to count, sort -nr to rank — is a pattern you will use for the rest of your career. Learn awk and sed at least at this level:

awk '{print $1, $9}' access.log | head        # print columns 1 and 9
sed 's/old-host/new-host/g' config.txt       # replace text (test without -i first)
cut -d' ' -f1 access.log | sort | uniq -c    # count requests per IP

Processes, Services and System Health

When a service is down, these commands tell you why.

ps aux | grep nginx          # show processes, filter for nginx
ps aux --sort=-%mem | head   # top memory users
top                          # live process view (htop is friendlier, if installed)
kill 1234                    # ask process 1234 to stop gracefully
kill -9 1234                 # force-kill it — last resort only
pkill -f "python app.py"     # kill by name pattern; check with pgrep first

On modern systems, services are managed by systemd. These commands are essential:

systemctl status nginx       # is it running? what do its recent logs say?
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl enable nginx       # start on boot
systemctl daemon-reload      # after editing a unit file
journalctl -u nginx -f       # follow a service's logs
journalctl -u nginx --since "1 hour ago"   # logs from the last hour
journalctl -p err --since today            # errors only, today

Disk, memory and load — check these before assuming an application bug:

df -h                        # disk space per filesystem
du -sh /var/log/* | sort -rh | head   # which directories are eating disk?
free -h                      # memory usage
uptime                       # load average and uptime
vmstat 1 5                   # memory and CPU snapshot

The classic production failure is a full disk: logs fill /var, the application cannot write, and everything fails at once. df -h and du -sh are the first commands to run, not the last. A related trap is a deleted file still held open by a process — lsof | grep deleted finds it.

Networking — the Commands That Find “Why Can’t I Reach It?”

Networking problems are the most common DevOps troubleshooting task. Work through them in order: local service, local port, DNS, route, remote port.

ss -tulpn                    # listening ports and the process behind each
ss -tulpn | grep :80         # is anything listening on port 80?
curl -I https://example.com  # check a site's headers and status
curl -v https://api.example.com/health   # verbose: see DNS, TLS and headers
ping -c 4 8.8.8.8            # basic connectivity
ping -c 4 example.com        # does DNS resolve?
dig example.com              # DNS details
nslookup example.com         # simpler DNS check
traceroute example.com       # where does the route break? (may be blocked)
wget https://example.com/file.tar.gz   # download a file

A troubleshooting sequence to memorise for “the application is not responding”:

  1. systemctl status <service> — is it running?
  2. ss -tulpn | grep <port> — is it listening?
  3. curl localhost:<port>/health — does it answer locally? If yes, the problem is networking or the load balancer, not the application.
  4. journalctl -u <service> --since "15 minutes ago" — what do the logs say?
  5. df -h; free -h — is the disk full or memory exhausted?

That five-step sequence solves a surprising number of incidents, and interviewers like candidates who can describe it calmly.

Users, SSH and Remote Work

You will spend much of your working life over SSH. Get comfortable with it.

ssh user@server.example.com          # connect
ssh -i ~/.ssh/key.pem user@server    # connect with a key file
scp app.tar.gz user@server:/opt/     # copy a file to a server
scp -r ./config user@server:/etc/app/   # copy a directory
rsync -avz ./app/ user@server:/opt/app/  # synchronise efficiently

Keep your private key private (chmod 600 ~/.ssh/id_ed25519), never share it, and never commit it to Git. If a key has ever been exposed, generate a new one and revoke the old one.

Users and sudo:

whoami
id
sudo -l                      # what am I allowed to run as sudo?
sudo systemctl restart nginx # run one command as root
su - appuser                 # switch user (needs the password or sudo)

On a server, prefer sudo for individual commands over logging in as root. Every sudo action is logged, which matters when an incident is reviewed later.

Text Editing, Archives and Package Management

Editing: learn one terminal editor properly. nano is the friendliest for beginners; vim is the standard on servers and is worth learning (i to insert, Esc then :wq to save and quit, :q! to quit without saving). You will need an editor in the CKA exam and on servers without a graphical interface, so do not rely on a desktop editor alone.

Archives and compression:

tar -czvf backup.tar.gz /opt/app/    # create a compressed archive
tar -xzvf backup.tar.gz -C /opt/     # extract it
gzip -d file.log.gz                   # decompress a log
unzip release.zip -d /opt/app/

Packages (Ubuntu/Debian vs RHEL-family):

sudo apt update && sudo apt install -y curl git   # Ubuntu/Debian
sudo apt upgrade -y                               # update installed packages
sudo yum install -y curl git                      # RHEL/CentOS (dnf on newer versions)

Know which family your servers use, and test package changes in a non-production environment first.

A Practical Cheat Sheet

Task Command
Where am I / what’s here? pwd, ls -lah
Find a file find /path -name "*.log"
Search logs for errors grep -rn "error" /var/log/ | tail
Follow a log live tail -f /var/log/syslog
Is the service running? systemctl status <service>
Service logs journalctl -u <service> --since "1 hour ago"
Disk full? df -h, then du -sh /var/* | sort -rh | head
What’s listening? ss -tulpn
Can I reach it? curl -v https://host/health
Who’s using memory? ps aux --sort=-%mem | head
Kill a stuck process kill <PID>, then kill -9 <PID> only if needed
Copy to a server scp file user@server:/path/

Frequently Asked Questions

How many Linux commands do I need to know for DevOps? About twenty, used fluently, plus the ability to read a man page (man grep) and combine commands with pipes. Depth in grep, awk, systemctl and journalctl matters more than memorising a hundred commands you never use.

Which Linux distribution should I learn? Ubuntu is the best starting point: it is the most common in cloud and tutorials, and its documentation is excellent. Once you are comfortable, learn the differences in RHEL-family systems (different package manager, SELinux, different file locations) — many enterprise employers use them.

Do I need to learn Vim? You need to be able to edit a file on a server without a graphical interface. nano is acceptable for that, but vim is installed almost everywhere and is required in the CKA exam environment. Learn the basics of vim even if you prefer another editor day to day.

What is the difference between kill and kill -9? kill (SIGTERM) asks a process to stop gracefully, so it can finish work and clean up. kill -9 (SIGKILL) forces it to stop immediately, which can leave files or data in an inconsistent state. Always try kill first.

How do I practise Linux safely? Use a virtual machine, a container, or a cheap cloud instance you can destroy and rebuild. Break things deliberately — fill a disk, stop a service, misconfigure a firewall — and practise fixing them. That is how the commands become reflexes.

Conclusion

Linux fluency is not about memorising a cheat sheet. It is about having a troubleshooting sequence you can run under pressure: check the service, check the port, check the logs, check the disk. Practise the commands in this guide on a disposable machine until the sequence is automatic, and keep a personal notes file of commands that saved you — it will become your most useful document. Then take the next step in our DevOps Engineer Roadmap 2026 and Kubernetes Tutorial for Beginners.

Practise today: open a terminal, run df -h, systemctl status, ss -tulpn and journalctl --since "1 hour ago", and write down what each one tells you about the machine you are on. Next, work through the Docker Tutorial for Beginners, then build a pipeline with the GitHub Actions Tutorial.

Scroll to Top