imara learning library ← all courses
Systems · Linux · 6 modules

Linux, from foundations to a hardened production host

The operating system your products run on, understood properly. Where Linux came from and how it got here, how it's actually built, and the four skills that matter in production: managing it, tuning it, hardening it, and configuring it — with Ubuntu and RedHat covered side by side.

6
modules: foundations → hardened host
4
interactive tools to try
2
families, Ubuntu & RedHat, throughout
100%
real commands you can run today
Module 01what it is, where it came from

Foundations & the long story

"Linux" is, strictly, just the kernel — the core program that talks to hardware. What you install and run is a distribution: that kernel plus the GNU userland tools, libraries, and a packaging system. Understanding that split explains almost everything else.

The Unix inheritance

Linux is a reimplementation of ideas from Unix (Bell Labs, 1969). From Unix it inherited a design philosophy that still shapes daily work: small tools that each do one thing well, connected by text streams, over a system where everything is a file. That philosophy is why you can chain simple commands into powerful one-liners, and why so much of the system is just readable text in files.

In 1991 Linus Torvalds wrote a free Unix-like kernel; combined with the GNU project's free tools, it became a complete, open operating system anyone could use and modify. That openness is why it ended up everywhere.

How it's built: kernel vs userland

Two worlds, exactly as in the Operating Systems course:

The shell is not special — it's just a userland program that reads your commands and asks the kernel to run them. "Everything is a file" takes the abstraction further: devices (/dev/sda), running-kernel state (/proc), even network sockets are accessed through the same file interface. One uniform way to touch everything.

The filesystem map (FHS)

Linux lays out directories by a standard, so you always know where to look:

PathHolds
/etcSystem configuration — all text, all editable
/varVariable data: logs (/var/log), spools, caches
/homeUsers' personal files
/usrInstalled software and its libraries
/bin, /sbinEssential commands (user / system)
/proc, /sysVirtual — live windows into the kernel, not real files
/devDevice files
/tmpTemporary scratch, often wiped on reboot

The two families: Ubuntu vs RedHat

Your products run on both, so know the lineages. Nearly everything differs only in packaging, defaults, and support model — the kernel and concepts are the same.

 Debian family (Ubuntu)RHEL family (RedHat)
MembersDebian → UbuntuRHEL → Rocky / Alma / CentOS, Fedora
Packages.deb · apt / dpkg.rpm · dnf / yum / rpm
Firewall frontendufwfirewalld
Security moduleAppArmorSELinux
Leans towardEase, fast-moving, huge communityEnterprise stability, paid support, long lifecycles

How it evolved to today

The arc in one paragraph: a hobby kernel in 1991 → the first distributions mid-90s bundling it into usable systems → dominance of the server room in the 2000s (the "LAMP" web stack) → the systemd transition in the 2010s, which unified how services start and are managed → and the cloud-and-container era, where Linux became the invisible substrate of essentially all cloud computing — containers are, after all, just a Linux-kernel feature. Today Linux runs almost every server, all of Android, and most embedded devices. It won by being open, stable, scriptable, and free.

Module 02literacy

The shell, files & permissions

The command line is where Linux is operated. It feels archaic until it clicks, then nothing else is as fast. Two things to master here: composing small tools, and the permission model that governs every file.

The shell and the essential verbs

The shell (usually bash) is a read-run loop for commands. A couple dozen tools cover most work:

the daily commands
ls -l        # list files, long form (perms, owner, size)
cd /var/log  # change directory
cat / less   # show a file / page through it
grep error   # search text for a pattern
find / -name "*.conf"   # locate files
cp · mv · rm · mkdir      # copy, move, remove, make dir
man ls       # the manual — your first stop

Pipes & redirection — the superpower

The Unix idea made practical: the pipe | feeds one tool's output into the next, and > redirects output to a file. Small tools compose into exactly the query you need:

composing tools
# which processes are running nginx, sorted?
ps aux | grep nginx | sort

# count error lines in a log, save to a file
grep -c "ERROR" /var/log/app.log > error_count.txt

# top 5 biggest directories here
du -sh * | sort -rh | head -5

The permission model

Every file has an owner, a group, and others, and for each of those three, up to three permissions: read, write, execute. That's the whole model, and ls -l shows it as a 9-character string like rwxr-xr-x.

Permissions are set with chmod, either symbolically (chmod u+x file) or as an octal number where r=4, w=2, x=1 added per group. So 755 = rwx (7) for owner, r-x (5) for group and others. Toggle the bits and watch the number:

Permissions calculator · click the bits
Common values: 644 (files: owner edits, others read), 755 (programs/dirs: all can run/enter, only owner edits), 600 (private: owner only — use for SSH keys).

Ownership is changed with chown user:group file. Two cautions: chmod 777 (everyone can do everything) is almost always a security mistake, and the SUID bit — which runs a program as its owner rather than the caller — is powerful and a classic privilege-escalation target, so audit it.

Module 03managing the running system

Processes, services & packages

Day-to-day administration is mostly this: seeing what's running, controlling services, and keeping software installed and patched. Modern Linux centres on one tool for the middle of those — systemd.

Processes & signals

Every running program is a process with a PID. You inspect them with ps aux or the live top / htop, and you control them by sending signals:

kill 1234 sends SIGTERM to PID 1234; kill -9 1234 forces it. Reach for -9 only when polite has failed.

systemd: the service manager

systemd is the first process the kernel starts (PID 1) and the manager for every service after it. You describe services as units and drive them with systemctl; their logs go to the journal, read with journalctl.

systemctl — same on Ubuntu & RedHat
systemctl status nginx     # is it running? recent logs
systemctl start nginx      # start now
systemctl stop nginx       # stop now
systemctl restart nginx    # stop then start
systemctl enable nginx     # start automatically at boot
journalctl -u nginx -f     # follow this service's logs live

A service moves between a few states. Drive one and watch:

Service lifecycle · systemctl in action
A crash lands the service in failed — where systemctl status and journalctl tell you why. With a restart policy set, systemd can auto-recover it.

Packages: the one real Ubuntu/RedHat difference you hit daily

install & update software
# Ubuntu / Debian (apt)
sudo apt update && sudo apt upgrade
sudo apt install nginx
sudo apt remove nginx

# RedHat / Rocky / Alma (dnf)
sudo dnf check-update
sudo dnf install nginx
sudo dnf remove nginx

Both pull from configured repositories, resolve dependencies, and track what's installed. Keeping packages current is also your first security control — more on that in Module 5.

Users & groups

Accounts live in /etc/passwd, group memberships in /etc/group. You add a user with useradd (or Ubuntu's friendlier adduser), grant admin rights by adding them to the sudo group (Ubuntu) or wheel group (RedHat), and they then run privileged commands via sudo — which logs every use.

Module 04making it fast

Performance & tuning

The golden rule: measure before you tune. Performance problems come from one of four resources — CPU, memory, disk I/O, or network — and the whole skill is identifying which before changing anything. Guessing wastes time and often makes things worse.

Load average — the most misread number

uptime and top show three load numbers (1, 5, 15-minute averages). The trap: a load of 4 is not inherently bad — you must read it relative to your core count. Load equal to cores means fully utilised; above cores means processes are queueing for CPU. Slide both and see:

Load average · always read it per-core
load ÷ cores is the real signal. Below ~0.7 per core: healthy headroom. Around 1.0: fully used. Above 1.0: work is waiting — investigate.

The tool for each resource

ResourceWatch withLooking for
CPUtop, mpstathigh %us (your code) or %sy (kernel), run-queue
Memoryfree -h, vmstatlow available, heavy swap use
Disk I/Oiostat, iotophigh %util, long await times
Networkss, iftop, ip -ssaturated links, dropped packets
"Free memory is wasted memory"

Linux deliberately fills unused RAM with disk cache to speed things up, and hands it back the instant a program needs it. So a nearly-full free -h is usually healthy, not alarming — look at the available column, not free. Real trouble is when the system starts heavy swapping (spilling memory to disk), which vmstat's si/so columns reveal.

Where the knobs are

Two interfaces expose the kernel's internals as files (everything-is-a-file again): /proc and /sys. Persistent tuning is done through sysctl:

kernel & limit tuning
# view and set kernel parameters
sysctl vm.swappiness              # how eagerly it swaps (lower = less)
sudo sysctl -w vm.swappiness=10   # try a value now
# make it permanent in /etc/sysctl.conf or /etc/sysctl.d/

# file-descriptor limit — servers hit this constantly
ulimit -n                         # current open-file limit
# raise it in /etc/security/limits.conf

Common high-value tunes for servers: raise the open-file-descriptor limit (busy services exhaust the default), lower swappiness on memory-rich hosts, and increase network connection backlogs (net.core.somaxconn) for high-traffic services. And recall from the cloud course: containers cap their resources with cgroups, the same kernel mechanism you can use directly.

Module 05locking it down

Security & hardening

For a platform handling customer financial data, this module isn't optional. Hardening is a few principles applied relentlessly: least privilege, minimise the attack surface, patch fast, and monitor. None are exotic; the discipline is in doing all of them.

Identity & access

Harden SSH — your front door

Most attacks start at SSH. In /etc/ssh/sshd_config, disable root login and password auth entirely:

/etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no      # keys only
# then: sudo systemctl restart sshd
# add fail2ban to auto-ban repeated failed attempts

Firewall — default deny

firewall: Ubuntu vs RedHat
# Ubuntu (ufw) — deny all in, allow only what you need
sudo ufw default deny incoming
sudo ufw allow 22/tcp && sudo ufw allow 443/tcp
sudo ufw enable

# RedHat (firewalld)
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Mandatory access control: SELinux & AppArmor

Standard permissions say what a user can do. Mandatory access control goes further, confining what each program can do even if compromised — so a breached web server can't read files outside its lane. RedHat ships SELinux (keep it Enforcing — don't disable it to fix a problem; write a policy); Ubuntu ships AppArmor (per-program profiles). Leaving these on is one of the highest-value, lowest-effort protections you have.

Patch, reduce, and watch

Toggle the controls below and watch the server's exposure drop — a good mental model for where risk actually lives:

Harden the host · click each control on
Don't reinvent the checklist

The CIS Benchmarks publish detailed, consensus hardening guides for Ubuntu and RHEL specifically — hundreds of concrete settings. For a regulated lender, working from a recognised benchmark is both good practice and far easier to defend in an audit than a homegrown list.

Module 06running it for real

Configuring & operating in production

Everything comes together here: configuration that's repeatable, storage that can grow, logs that don't fill the disk, and automation so you manage a fleet instead of pets. The goal is a host that's reproducible, not hand-crafted.

Configuration is text in /etc — so version it

Almost all Linux configuration is plain text under /etc. That's a gift: you can read it, diff it, and put it in version control. Hand-editing one server is fine; hand-editing fifty is how drift and outages happen. At scale, describe the desired state in Ansible (agentless, declarative — the same idea as Terraform from the cloud course, but for configuring the inside of hosts) and apply it uniformly.

Logging — and not running out of disk

Logs live in the systemd journal (journalctl) and as text in /var/log. Unmanaged, they will eventually fill the disk and take the host down — a classic 3am incident. logrotate automatically compresses and expires old logs; for a fleet, ship logs to a central system so you can search across hosts.

Storage: filesystems, mounts & LVM

Disks are formatted with a filesystem (ext4 is the Ubuntu default, xfs RedHat's) and attached at a mount point, with permanent mounts defined in /etc/fstab. Use LVM (Logical Volume Manager) rather than raw partitions so you can resize and extend storage later without rebuilding — the difference between a five-minute disk expansion and a painful migration.

everyday storage checks
df -h          # free space per filesystem — check before it bites
du -sh /var/*  # what's using space under /var
lsblk          # block devices and mounts
# LVM: extend a volume by 10G, then grow the filesystem
sudo lvextend -L +10G /dev/vg0/data && sudo resize2fs /dev/vg0/data

Automation: scheduled work

Recurring jobs run via classic cron or modern systemd timers (which log to the journal and handle missed runs better). A few lines of shell script plus a timer handles backups, cleanups, and health checks — the quiet machinery that keeps production healthy.

The production-ready checklist

Pulling the whole course together — before a Linux host serves real traffic:

Ubuntu ↔ RedHat quick reference

TaskUbuntuRedHat
Install a packageapt installdnf install
Update everythingapt update && apt upgradednf upgrade
Firewallufwfirewalld
Access controlAppArmorSELinux
Auto security updatesunattended-upgradesdnf-automatic
Network confignetplanNetworkManager
Grant adminsudo groupwheel group
Default filesystemext4xfs

You can now run Linux with intent

From the kernel-and-userland foundations and the long road from Unix to the cloud, through the shell and permissions, service and package management, performance tuning, hardening, and reproducible production configuration — you have the working mental model and the commands to understand, secure, tune, configure and manage the Linux hosts your products depend on, on both Ubuntu and RedHat.