Linux is a fundamental skill for any DevOps engineer, and for almost any technical role. Your servers run Linux. Your Docker containers are Linux processes. Every Kubernetes node is a Linux machine. Your CI/CD runners are almost certainly Linux too. Sooner or later, something breaks on one of these machines and you are the one who has to SSH in and fix it.
The good news: you don't need to know Linux as deeply as a system administrator. You don't need to compile kernels or manage LDAP. You need to be comfortable and fast on the command line, and to know where to look when things go wrong.
This guide is step 1 of the DevOps roadmap. It covers exactly what to learn, the commands you'll actually use on the job, and a small exercise for each section.
How to use this guide: don't just read it. Spin up a free Linux VM (or use WSL on Windows, or a cheap cloud instance) and type every command as you go. Muscle memory is the whole point.
What to learn (and what to skip)
| Learn this well | Know it exists, don't go deep |
|---|---|
| Navigating the filesystem | Kernel compilation and tuning |
| Permissions and ownership | SELinux / AppArmor policy writing |
| SSH and remote servers | Advanced iptables / nftables rules |
| Processes and signals | LVM, RAID and filesystem internals |
| Package managers and systemd | Mail servers, LDAP, printing |
| Basic networking commands | Writing large programs in Bash |
| Troubleshooting disk, memory and CPU | |
| Bash scripting for automation |
1. Understand Linux as a system
Before the commands, it helps to have a mental model of what Linux actually is.
Strictly speaking, Linux is a kernel: the core program that talks to the hardware (CPU, memory, disks, network cards). What you install, such as Ubuntu, Debian, Rocky or Amazon Linux, is a distribution: the kernel plus tools, a package manager and defaults.

A running Linux system is split into two worlds:
- Kernel space: where the kernel runs, with full access to the hardware.
- User space: where everything else runs: your shell, your apps, Python, Docker, nginx.
Programs in user space can't touch the hardware directly. When they need to open a file, send data over the network or start a new process, they ask the kernel through a system call (syscall). Syscalls are the bridge between the two worlds.
You can actually watch this happen:
strace -c ls # count every syscall that `ls` makesWhy this matters for DevOps: containers are not magic virtual machines. A container is just a normal Linux process that the kernel isolates using features called namespaces (what the process can see) and cgroups (how much CPU and memory it can use). Once that clicks, Docker and Kubernetes make far more sense. We'll come back to this in the Containers step.
2. Navigating the filesystem
These commands are your bread and butter. You will use them every single day as a DevOps engineer.
pwd # where am I?
ls -la # list everything, including hidden files, with details
cd /var/log # move to a directory
cd ~ # go to your home directory
cd - # go back to the previous directory
mkdir -p app/config # create a directory (and parents if needed)
touch app/config/app.env # create an empty file
cp -r app app-backup # copy a directory recursively
mv app.env app.env.old # move or rename
rm -r app-backup # delete (there is no recycle bin, so be careful)
cat file.txt # print a file
less /var/log/syslog # scroll through a big file (q to quit)
head -n 20 file.txt # first 20 lines
tail -f /var/log/nginx/access.log # follow a log live
find / -name "*.conf" 2>/dev/null # find files by name
grep -rn "error" /var/log/ # search inside filesThe Linux directory tree
Everything starts at / (the root of the filesystem). These are the directories you'll meet constantly:
| Directory | What lives there |
|---|---|
/ | The top of the tree. Everything is under here. |
/home | Home directories for normal users (/home/isreal). |
/root | Home directory of the root user. |
/etc | System-wide configuration: /etc/nginx/, /etc/ssh/sshd_config, /etc/hosts. |
/var | Data that changes: logs in /var/log, Docker data in /var/lib/docker. |
/tmp | Temporary files, often wiped on reboot. |
/usr | Installed programs and libraries (/usr/bin, /usr/lib). |
/opt | Optional, third-party software. |
/proc | A virtual window into running processes and the kernel. |
/dev | Devices, such as disks (/dev/sda) and /dev/null. |
Everything is a file
In Linux, almost everything is represented as a file: config, logs, devices, even running processes. Try these:
cat /proc/cpuinfo # your CPU, as a file
cat /proc/meminfo # memory stats, as a file
ls /proc/1/ # everything about process ID 1
echo "hello" > /dev/null # the "black hole" deviceThis idea is why so much of DevOps work is just reading and editing text files.
Practise this: create a directory structure ~/practice/{logs,config,scripts}. Find every .conf file under /etc, then use grep to find which one mentions PermitRootLogin.
3. File permissions and ownership
You'll often hit Permission denied. Understanding why is essential.
Run ls -l and you'll see something like:
-rwxr-x--- 1 deploy devops 2048 Nov 20 10:00 deploy.shBreak down -rwxr-x---:
- The first character is the type:
-for a file,dfor a directory,lfor a link. - Then three groups of three: user (owner)
rwx, groupr-x, others---. r= read,w= write,x= execute (for directories,xmeans "can enter").
So deploy can do everything, members of devops can read and run it, and everyone else gets nothing.
Changing permissions
Each permission has a number: r=4, w=2, x=1. Add them up per group:
chmod 755 deploy.sh # rwxr-xr-x: owner full, everyone else read + execute
chmod 644 config.yml # rw-r--r--: owner read/write, everyone else read
chmod 600 id_ed25519 # rw-------: private keys must be owner-only
chmod +x deploy.sh # make a script executable (symbolic form)
chmod -R g+w shared/ # give the group write access, recursivelyChanging ownership
sudo chown deploy deploy.sh # change the owner
sudo chown deploy:devops deploy.sh # change owner and group
sudo chown -R www-data:www-data /var/www/app # recursively, e.g. for a web serversudo runs a command as root. Use it when you need to, not by default.
Classic scenario: you write
deploy.sh, run./deploy.shand getPermission denied. The file isn't executable.chmod +x deploy.shfixes it.
Practise this: create a script, try to run it, fix the permission error. Then create a new user, make a file only that user can read, and confirm your normal user can't cat it.
4. SSH: working on remote servers
As a DevOps engineer, most servers you touch won't be in front of you. SSH (Secure Shell) is how you connect to them.
Connecting
ssh ubuntu@203.0.113.10 # connect as user "ubuntu"
ssh -i ~/.ssh/my-key.pem ubuntu@203.0.113.10 # with a specific key (common on AWS)
ssh -p 2222 ubuntu@203.0.113.10 # on a non-default portKey-based authentication
Passwords are weak; keys are the standard. You generate a key pair: the private key stays on your laptop, and the public key goes on the server.
ssh-keygen -t ed25519 -C "isreal@laptop" # creates ~/.ssh/id_ed25519 and id_ed25519.pub
ssh-copy-id ubuntu@203.0.113.10 # copies your public key to the serverssh-copy-id simply appends your public key to ~/.ssh/authorized_keys on the server. You can do it by hand too, but permissions must be strict or SSH will ignore the file:
mkdir -p ~/.ssh && chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keysGiving a teammate access
sudo adduser alice # create the user
sudo usermod -aG sudo alice # optional: allow sudo (use "wheel" on RHEL-based systems)
sudo mkdir -p /home/alice/.ssh
sudo nano /home/alice/.ssh/authorized_keys # paste Alice's PUBLIC key
sudo chown -R alice:alice /home/alice/.ssh
sudo chmod 700 /home/alice/.ssh && sudo chmod 600 /home/alice/.ssh/authorized_keysSave time with ~/.ssh/config
Host web1
HostName 203.0.113.10
User ubuntu
IdentityFile ~/.ssh/my-key.pemNow ssh web1 is all you need.
Copying files
scp app.tar.gz web1:/tmp/ # copy a file to the server
rsync -avz ./site/ web1:/var/www/site/ # sync a directory (faster for repeat copies)Port forwarding
Say a database or admin dashboard on the server only listens on localhost:5432, so it isn't exposed to the internet. You can still reach it safely through SSH:
ssh -L 5432:localhost:5432 web1Now connecting to localhost:5432 on your laptop goes through the tunnel to the server. This is perfect for testing connectivity without opening firewall ports.
Basic hardening
In /etc/ssh/sshd_config, once key login works:
PasswordAuthentication no
PermitRootLogin noThen sudo systemctl restart ssh (named sshd on some distros). Keep your current session open until you've confirmed you can log in from a new terminal, or you can lock yourself out.
Practise this: create two VMs. Set up key-only SSH from one to the other, add a second user with their own key, and use -L to reach a web server on the remote machine that only listens on localhost.
5. Processes
As a DevOps engineer, you manage Linux processes all the time. Your application is a process. Your Python program is a process. Your Docker containers are processes. Your Kubernetes pods are processes too. Knowing how to inspect and control them is core.
Listing and finding processes
ps aux # every process on the system
ps aux | grep nginx # find a specific one
pgrep -a python # find processes by name, with their command line
top # live view: CPU, memory, load (q to quit)
htop # a friendlier top (may need installing)Every process has a PID (process ID) and a parent (PPID). pstree -p shows the family tree.
Stopping processes and signals
You stop a process by sending it a signal:
kill 1234 # sends SIGTERM (15): "please shut down cleanly"
kill -9 1234 # sends SIGKILL (9): "stop now", no cleanup possible
pkill -f "gunicorn" # kill by name or command lineAlways try SIGTERM first. SIGKILL can't be caught, so the app never gets the chance to flush data or close connections. This matters in Kubernetes too: when a pod is deleted, it gets SIGTERM first, then SIGKILL after a grace period.
Background jobs
./long-task.sh & # run in the background
jobs # list background jobs
fg %1 # bring job 1 back to the foreground
nohup ./long-task.sh & # keep running after you log outFor anything long-lived in production, don't rely on nohup. Run it as a systemd service (next section).
Which port is a process using?
sudo ss -tulpn # every listening port and the process behind it
sudo ss -tulpn | grep :8080 # who's on port 8080?
sudo lsof -i :8080 # same question, different toolPractise this: run python3 -m http.server 8000 &. Find its PID three different ways (ps, pgrep, ss), then stop it with SIGTERM.
6. Installing packages and managing services
As a DevOps engineer, you'll install and manage software on servers: Docker, container runtimes, Prometheus exporters, nginx, monitoring agents and more.
Package managers
A package manager downloads software from trusted repositories, installs it with its dependencies, and keeps it updated. Which one you use depends on the distro family:
| Distro family | Package manager |
|---|---|
| Debian, Ubuntu | apt |
| RHEL, Rocky, Fedora, Amazon Linux | dnf (older: yum) |
| Alpine (common in containers) | apk |
sudo apt update # refresh the list of available packages
apt search nginx # find a package
sudo apt install -y nginx # install it
sudo apt upgrade # upgrade installed packages
sudo apt remove nginx # remove it
sudo dnf install -y nginx # the same idea on RHEL-family systemsSome tools (like Docker or Kubernetes packages) need you to add the vendor's own repository first. Always follow the official install docs for those.
systemd and systemctl
Most modern distros use systemd to start and supervise services. systemctl is how you control it:
sudo systemctl start nginx # start now
sudo systemctl stop nginx # stop
sudo systemctl restart nginx # restart (e.g. after a config change)
sudo systemctl reload nginx # reload config without dropping connections
sudo systemctl enable nginx # start automatically on boot
sudo systemctl enable --now nginx # enable and start in one go
systemctl status nginx # is it running? recent logs too
systemctl list-units --type=service --state=failed # what's broken?When a service won't start, the logs are in the journal:
journalctl -u nginx # all logs for nginx
journalctl -u nginx -f # follow live
journalctl -u nginx --since "10 min ago"Practise this: install nginx, enable it on boot, confirm it with curl localhost, reboot the VM, and confirm it came back on its own. Then break its config on purpose, try to restart, and use journalctl to find the error.
7. Networking on the box
Networking gets its own step in the roadmap. Here is the foundation you need on any Linux machine.
ip a # network interfaces and their IP addresses
ip route # routing table, including the default gateway
sudo ss -tulpn # open (listening) ports and which process owns them
ping -c 4 8.8.8.8 # can I reach that IP at all?
dig google.com # DNS lookup (or: nslookup google.com)
curl -v http://localhost:8080/health # make an HTTP request and see the details
cat /etc/hosts # local hostname overridesBinding to an address
When an app listens on a port, it also binds to an address. This catches people out constantly:
127.0.0.1:8080means only reachable from the same machine.0.0.0.0:8080means reachable on all interfaces, including from outside.
If your app works with curl localhost:8080 on the server but not from your laptop, check ss -tulpn. It's probably bound to 127.0.0.1. Also, ports below 1024 (like 80 and 443) need root privileges to bind.
Firewalls (just the basics)
On Ubuntu, ufw is the friendly option:
sudo ufw allow OpenSSH # don't lock yourself out!
sudo ufw allow 80/tcp
sudo ufw enable
sudo ufw statusUnder the hood this is iptables / nftables. Know they exist, but don't go too deep. In the cloud, you'll mostly use security groups instead.
Practise this: run a simple web server bound to 127.0.0.1, prove you can't reach it from another machine, rebind it to 0.0.0.0, then use ufw to allow only port 80.
8. Resource management and troubleshooting
At some point, a server will run out of disk, run out of memory, or slow to a crawl, and you need to find out why and bring it back. This is one of the most valuable skills you can have on call.
Disk
df -h # disk usage per filesystem
du -sh /var/* | sort -h # which directories are biggest?
du -sh /var/log/* | sort -h # usually the culprit: logsGotcha: the disk is full but you can't find the files. If a process still has a deleted file open (often a huge log), the space isn't freed until that process lets go:
sudo lsof +L1 # list deleted files that are still openRestart that process, or truncate the file instead of deleting it. To empty a huge log safely while the app keeps writing to it:
sudo truncate -s 0 /var/log/myapp/app.log # empty it in placeUsing rm on a log that's still open frees nothing until the process restarts.
Memory
free -h # total, used and available memory
top # press M to sort by memory
ps aux --sort=-%mem | head # top memory usersLook at available, not "free". Linux uses spare memory for caching, and that's a good thing. If memory runs out completely, the kernel's OOM killer picks a process and kills it:
sudo dmesg -T | grep -i "killed process" # did the OOM killer strike?CPU and load
uptime # load average over 1, 5 and 15 minutes
top # press P to sort by CPU
nproc # number of CPU coresA load average consistently higher than your number of cores means work is queuing up.
File descriptors
Every open file, socket and connection uses a file descriptor, and there are limits. Busy apps can hit them and fail with Too many open files:
ulimit -n # the limit for your shell
ls /proc/1234/fd | wc -l # how many process 1234 has openA quick "server is unhealthy" checklist
uptime: is load high?df -h: is a disk full?free -h: is memory exhausted? Checkdmesgfor OOM kills.top: which process is eating CPU or memory?systemctl status <service>andjournalctl -u <service>: what does the app say?ss -tulpn: is it still listening on its port?
Practise this: fill a disk on purpose with fallocate -l 2G bigfile, find it with du, and clean it up. Then write a tiny script that leaks memory and watch it with top until the OOM killer steps in.
9. Bash scripting
Once you're comfortable on the command line, the next step is automating what you do by hand. Bash scripts glue DevOps work together: setup scripts, health checks, backups, CI pipeline steps and container entrypoints.
Your first script
#!/usr/bin/env bash
set -euo pipefail
echo "Hello from $(hostname)"- The first line (the shebang) says which interpreter runs the script.
set -euo pipefailmakes the script stop on errors, treat unset variables as errors, and catch failures inside pipes. Put it at the top of every script.
Save it as hello.sh, then chmod +x hello.sh && ./hello.sh.
The building blocks
# Variables (no spaces around =), and always quote them
NAME="barilon"
echo "Deploying ${NAME}"
# Arguments passed to the script
ENVIRONMENT="${1:-staging}" # first argument, default "staging"
echo "All arguments: $@"
# Command substitution
TODAY=$(date +%F)
# Conditions
if [[ -f /etc/nginx/nginx.conf ]]; then
echo "nginx is configured"
elif [[ "$ENVIRONMENT" == "prod" ]]; then
echo "prod without nginx config!"
else
echo "nothing to do"
fi
# Loops
for server in web1 web2 web3; do
ssh "$server" "uptime"
done
while read -r line; do
echo "Line: $line"
done < servers.txt
# Functions
log() {
echo "[$(date +%T)] $*"
}
log "Starting backup"Exit codes, pipes and redirection
Every command returns an exit code: 0 means success, anything else means failure. That's how scripts and CI pipelines know whether something worked.
grep -q "ERROR" app.log
echo $? # 0 if found, 1 if not
./deploy.sh > deploy.log # stdout to a file (overwrite)
./deploy.sh >> deploy.log # append
./deploy.sh > deploy.log 2>&1 # stdout AND errors to the file
cat access.log | grep 500 | wc -l # pipes: chain commands togetherScheduling with cron
crontab -e# minute hour day month weekday command
*/5 * * * * /opt/scripts/disk-check.sh >> /var/log/disk-check.log 2>&1
0 2 * * * /opt/scripts/backup.shA real example: disk usage alert
This ties the last section together. It checks every filesystem and warns when one is above a threshold:
#!/usr/bin/env bash
set -euo pipefail
THRESHOLD="${1:-80}" # percent; pass a different value as the first argument
STATUS=0
while read -r usage mount; do
percent="${usage%\%}" # strip the % sign
if (( percent >= THRESHOLD )); then
echo "WARNING: ${mount} is at ${usage}"
STATUS=1
fi
done < <(df -h --output=pcent,target -x tmpfs -x devtmpfs | tail -n +2)
if (( STATUS == 0 )); then
echo "All filesystems below ${THRESHOLD}%"
fi
exit "$STATUS"It exits with 1 when any disk is too full, so you can run it from cron, a CI job or a monitoring check and act on the result.
What to skip
Don't try to become a Bash wizard. When a script grows past about 100 lines, needs real data structures, or has to call APIs and parse JSON, reach for Python instead. Bash is for gluing commands together; it isn't a general programming language.
Practise this: write a script that takes a service name as an argument, checks whether it's running with systemctl is-active, restarts it if not, and logs what it did with a timestamp. Schedule it with cron every five minutes.
Mini project
Time to put it all together on a real server.
Deploy and manage a real web application on a Linux server, using everything from this guide: SSH, users and permissions, packages, systemd, networking, troubleshooting and a Bash script to tie it together.
👉 Start the project: Linux Fundamentals — Deploy and Manage a Web Application
Interview questions you should be able to answer
If you've worked through this guide, you should be able to answer these confidently:
- What happens, step by step, when you type
lsand press Enter? - What's the difference between permissions
755and644, and when would you use each? - A service won't start after a config change. Walk me through how you'd debug it.
- How do you find which process is listening on port 80?
dfsays the disk is 100% full, butdudoesn't add up. What's going on?- What's the difference between
SIGTERMandSIGKILL? - What does
set -euo pipefaildo, and why use it?
Want the full answers, plus more Linux and DevOps questions? Head to Interview Prep →
Prefer to practise out loud? Book a mock interview and get feedback before the real one.
What's next
You've got the foundation every other step builds on. Next on the roadmap is Networking: TCP/IP, DNS, HTTP, load balancing and how traffic really flows between machines.
