Every DevOps roadmap, mine included, starts with "learn Linux" as step one, and it's tempting to treat that as a box to tick before getting to the "real" stuff — Docker, Kubernetes, Terraform. That's backwards. Every one of those tools is Linux underneath, running as processes, writing logs, respecting file permissions, managed by the same init system. This post is the actual foundation: permissions, processes, systemd, and the handful of command-line tools you'll reach for constantly once you're actually debugging something at 2am.
Permissions: Who Can Do What to a File
Everything in Linux is designed around one question: who is allowed to read, write, or execute this thing? Run ls -l on any file and the permission string at the start tells you the whole answer:
-rwxr-xr-- 1 daemon devteam 4096 Aug 20 14:02 deploy.sh Break that first block into four pieces: the file type (- for a regular file, d for a directory), then three groups of three characters — permissions for the owner, the group, and everyone else, in that order. Each group is r (read), w (write), x (execute), or - if that permission isn't granted. So rwxr-xr-- means: the owner can read, write, and execute; the group can read and execute but not write; everyone else can only read.
Octal Notation — Why chmod 755 Means What It Means
Each rwx triplet can be represented as a single number by treating r, w, and x as bit values — r = 4, w = 2, x = 1 — and adding up whichever ones are granted:
| Permission | Value |
|---|---|
| Read (r) | 4 |
| Write (w) | 2 |
| Execute (x) | 1 |
rwx = 4+2+1 = 7. r-x = 4+1 = 5. r-- = 4 = 4. So chmod 755 deploy.sh sets owner to rwx (7), group to r-x (5), and everyone else to r-x (5) — a very common pattern for an executable script that everyone should be able to run but only the owner should be able to edit. chmod 644 (owner: read/write, everyone else: read-only) is the equivalent pattern for a regular non-executable file, like a config file.
chmod 755 deploy.sh # owner: rwx, group: r-x, other: r-x chmod +x deploy.sh # just add execute permission for everyone, without touching the rest chmod u+w,g-w config.yml # owner gains write, group loses write Ownership: chown and chgrp
Permissions only mean anything relative to who actually owns the file. chown changes the owning user (and optionally the group in the same command); chgrp changes just the group:
sudo chown daemon:devteam deploy.sh # owner: daemon, group: devteam sudo chown -R daemon:devteam /var/www/app # recursively, for every file in a directory The -R flag matters constantly in real work — a misconfigured deploy that leaves files owned by root when your application runs as a non-root user is one of the most common "why won't my app start" issues you'll hit, and it's always a chown -R fix once you know what to look for.
sudo vs. su
sudo runs a single command with elevated privileges, then drops back to your normal user immediately after. su switches your entire shell session to another user (root, by default, if no username is given) until you explicitly exit that session. In almost all modern practice, sudo is the better habit — it's scoped to exactly the one command that needs elevation, it's logged per-command, and it doesn't leave you sitting in a root shell longer than necessary, which is exactly the kind of thing that turns a typo into a real incident.
Processes: What's Actually Running
A process is a running instance of a program, and Linux gives every single one a PID (Process ID) the moment it starts. Everything you'll ever debug on a server eventually comes down to "what process is doing this, and what state is it in."
ps aux # every process running on the system, in detail ps aux | grep nginx # just the ones matching "nginx" top # live, auto-refreshing view of processes by CPU/memory usage htop # the same idea, with a much friendlier interface (install it, it's worth it) ps aux output tells you the user running each process, its PID, CPU and memory usage, and the actual command that started it — which is usually the fastest way to answer "is this thing even running" before digging any further.
Killing Processes: Signals, Not Just "Stop"
kill doesn't just forcefully terminate a process — it sends it a signal, and different signals mean different things, some of which the process can choose to handle gracefully:
kill 4821 # sends SIGTERM (15) — "please shut down cleanly" kill -9 4821 # sends SIGKILL (9) — "stop immediately, no cleanup, no choice" kill -HUP 4821 # sends SIGHUP (1) — many daemons treat this as "reload your config" SIGTERM is the polite version — it asks the process to shut down, and a well-written application catches that signal and does cleanup first (closing database connections, finishing an in-flight request, flushing logs) before actually exiting. SIGKILL is the process getting no say in the matter at all — the kernel terminates it immediately, which means anything mid-write or mid-cleanup just stops where it was. Always reach for a plain kill (SIGTERM) first, and only escalate to kill -9 if the process genuinely isn't responding — killing a database process with -9 mid-write is a real way to corrupt data.
Foreground, Background, and Keeping Things Running
long-running-script.sh & # run in the background, get your terminal prompt back immediately jobs # list background jobs in the current session fg %1 # bring job 1 back to the foreground nohup long-running-script.sh & # run in the background AND survive you logging out of the session nohup matters specifically because a background job started with just & still dies the moment your SSH session ends — the shell sends it a hangup signal on logout. nohup ("no hangup") detaches it from that. In real production work you'd generally reach for something more robust than either — a proper systemd service, screen, or tmux — but knowing why a script died the second you closed your laptop lid is exactly the kind of foundational understanding that saves you an hour of confusion the first time it happens.
systemd: How Modern Linux Actually Manages Services
Almost every modern Linux distribution uses systemd as its init system — the very first process the kernel starts (always PID 1), responsible for bringing up every other service on the machine and keeping them running.
Units and systemctl
Everything systemd manages is a unit, and the most common type by far is a service unit (.service), representing one long-running background process — Nginx, Docker, your own application, if you set it up that way.
sudo systemctl status nginx # is it running, since when, recent log lines sudo systemctl start nginx # start it now sudo systemctl stop nginx # stop it now sudo systemctl restart nginx # stop then start sudo systemctl reload nginx # ask it to reload config without a full restart, if it supports this sudo systemctl enable nginx # start automatically on every future boot sudo systemctl disable nginx # stop starting automatically on boot The distinction between enable/disable and start/stop trips people up constantly: start/stop control whether something is running right now; enable/disable control whether it will start automatically the next time the machine boots. You can absolutely have a service that's running right now but not enabled (it won't survive a reboot), or enabled but not currently running (you stopped it manually, but it'll come back on the next boot regardless).
Writing Your Own Service Unit
This is genuinely one of the most useful things you can learn early — instead of running your application in a terminal with nohup and hoping for the best, give it a real unit file at /etc/systemd/system/myapp.service:
[Unit] Description=My Application After=network.target [Service] ExecStart=/usr/bin/python3 /opt/myapp/app.py Restart=on-failure User=daemon WorkingDirectory=/opt/myapp [Install] WantedBy=multi-user.target Restart=on-failure alone is worth the entire exercise — systemd will automatically restart your application if it crashes, something a plain nohup'd process will never do on its own. After creating the file: sudo systemctl daemon-reload (tell systemd to notice the new unit file), then sudo systemctl enable --now myapp (enable on boot and start it immediately in one command).
journalctl: Where All the Logs Actually Went
systemd centralizes logs from every service it manages into the journal, and journalctl is how you read it — no more hunting through a dozen different log files in /var/log hoping you picked the right one.
journalctl -u nginx # every logged line for the nginx unit specifically journalctl -u nginx -f # follow it live, like tail -f journalctl -u nginx --since today journalctl -u nginx --since "1 hour ago" journalctl -p err # only entries at "error" priority or higher, across everything journalctl -b # everything logged since the current boot journalctl --disk-usage # how much space the journal itself is using journalctl -u <service> -f is the command you will type without thinking about it once systemd habits set in — it's the direct equivalent of watching a service's logs stream in real time as you restart it or send it traffic, and it's usually the very first thing to check when a service that should be running isn't behaving.
The Text-Processing Trio: grep, sed, awk
These three do almost everything you'll ever need for filtering and manipulating text — log files, config files, command output — directly in the terminal, without opening an editor.
grep — Find Lines That Match
grep "ERROR" app.log # lines containing "ERROR" grep -i "error" app.log # case-insensitive grep -v "DEBUG" app.log # every line that does NOT contain "DEBUG" grep -r "TODO" ./src # recursively search every file under ./src grep -n "timeout" app.log # show the line number of each match grep -c "ERROR" app.log # just count how many matching lines there are grep -E "error|fail|exception" app.log # extended regex — match any of several patterns grep is almost always the first tool you reach for: "does this log even contain the thing I'm looking for" is usually the very first question in any debugging session.
sed — Find and Replace, Stream-Style
sed (stream editor) processes text line by line, most commonly to find and replace:
sed 's/staging/production/' config.yml # replace the first match per line sed 's/staging/production/g' config.yml # replace every match per line (global) sed -i 's/staging/production/g' config.yml # do it in place, actually editing the file sed -n '10,20p' app.log # print only lines 10 through 20 sed '/^#/d' config.yml # delete every line starting with # (comments) The -i flag is the one to be genuinely careful with — it edits the file directly, with no confirmation and no undo. Running the command without -i first, checking the output looks right, then re-running with -i, is a habit worth building early.
awk — When You Need Specific Columns, Not Just Matching Lines
awk is really a small programming language built around processing text as rows and columns, which makes it the right tool the moment grep and sed aren't quite enough:
awk '{print $1}' access.log # print just the first column (whitespace-separated) awk -F',' '{print $2}' data.csv # use a comma as the field separator instead of whitespace awk '{print $1, $NF}' access.log # first column and the last column ($NF = number of fields) awk '/ERROR/ {print $0}' app.log # print full lines matching a pattern, like grep awk '{sum += $3} END {print sum}' data.txt # sum up column 3 across every line That last example is the kind of thing that separates awk from grep/sed — it's genuinely doing arithmetic across a file, which makes it the tool of choice for quick one-off log analysis: total bytes transferred, count of requests per status code, average response time — all doable in a single line without writing a script.
Chaining Them Together
The real power shows up when you pipe these into each other, which is the actual daily workflow far more often than using any one of them alone:
grep "ERROR" app.log | awk '{print $1, $2}' | sort | uniq -c | sort -rn Read left to right: find every error line, pull out just the date and time columns, sort them, count how many times each unique date/time appears, then sort that by count, highest first. That single line answers "when did most of my errors happen" without opening a single file in an editor — and it's built entirely out of small tools that each do one thing well, chained together with pipes. That's the actual Unix philosophy in practice, and it's worth internalizing early: you don't need one giant tool that does everything, you need a handful of small tools you deeply understand and the habit of piping them together.
Why All of This Actually Matters
Every layer above — permissions, processes, systemd, log analysis — is the thing you're actually doing every time you "use Docker" or "deploy to Kubernetes," just abstracted a level up. A container is a process with restricted permissions and its own view of the filesystem. A Kubernetes Pod restarting on failure is the exact same idea as Restart=on-failure in a systemd unit, just orchestrated across a cluster instead of a single machine. kubectl logs is conceptually journalctl -f for a container instead of a systemd unit. None of the tools change what they fundamentally are — they just add more machinery on top of the same Linux primitives you now actually understand.
Get comfortable enough with this that none of it requires looking anything up, and the tools coming later in the roadmap — Docker, Kubernetes, Terraform — stop being new concepts to learn from scratch and start being new interfaces on top of things you already understand cold.