A Practice Server & How the Sessions Run
Server administration is learned on servers. This lesson sets up two places to practise: the sandbox behind the sessions in this course, and a practice VM of your own for everything that needs root.
What the sandbox can and cannot do
Every bash block with an output in this course ran in a fresh Ubuntu 24.04 container as the user learner, with no network. That is a realistic slice of a server, with three hard limits:
| Limit | Consequence | What the lessons do instead |
|---|---|---|
| No root | useradd, mount, lvcreate, nft, apt install fail |
sample sessions with realistic output |
| No systemd as PID 1 | systemctl start, journalctl on a live journal, timers firing |
systemd-analyze verify, calendar, security --offline on unit files |
No network, no CAP_NET_ADMIN |
no public DNS, no Let's Encrypt, no firewall rules, no packet capture | local servers on 127.0.0.1, dnsmasq on port 5353, a private CA, tcpdump -r on saved captures |
Inside those limits a lot is real: Nginx, Caddy and HAProxy run unprivileged on ports above 1024, OpenSSL builds a CA and talks TLS to a local server, sshd -t and visudo -c check configs, fail2ban-regex tests filters, logrotate and rsync work on your own files. Here is the bench:
id
hostname
for t in systemd-analyze sshd nginx caddy haproxy openssl dnsmasq dig tcpdump rsync logrotate fail2ban-regex; do
printf '%-16s %s\n' "$t" "$(command -v $t)"
done
systemd-analyze --version | head -1
nginx -v 2>&1
caddy version | cut -d' ' -f1
openssl version
ip -br addruid=1000(learner) gid=1000(learner) groups=1000(learner)
tad
systemd-analyze /usr/bin/systemd-analyze
sshd /usr/sbin/sshd
nginx /usr/sbin/nginx
caddy /usr/local/bin/caddy
haproxy /usr/sbin/haproxy
openssl /usr/bin/openssl
dnsmasq /usr/sbin/dnsmasq
dig /usr/bin/dig
tcpdump /usr/bin/tcpdump
rsync /usr/bin/rsync
logrotate /usr/sbin/logrotate
fail2ban-regex /usr/bin/fail2ban-regex
systemd 255 (255.4-1ubuntu8.18)
nginx version: nginx/1.24.0 (Ubuntu)
v2.11.7
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024)
lo UNKNOWN 127.0.0.1/8 ::1/128
The only interface is loopback (lo): every server in these sessions listens on 127.0.0.1, and the client is on the same machine.
A practice VM of your own
For the sample sessions, use a throwaway VM where breaking things costs nothing. Any of these works; pick the one that fits your machine:
| Option | Command to get a shell | Notes |
|---|---|---|
| Multipass (Linux, macOS, Windows) | multipass launch 24.04 --name lab --disk 20G then multipass shell lab |
real systemd, snapshots with multipass snapshot |
| Vagrant + VirtualBox/libvirt | vagrant init bento/ubuntu-24.04 && vagrant up && vagrant ssh |
add a second virtual disk for the LVM lessons |
| A small cloud VM | create an Ubuntu 24.04 instance with your SSH key | real public IP: harden SSH first, and delete it when done (check current pricing) |
| systemd in a container | not recommended | containers usually don't run systemd as PID 1; you would be debugging the container, not the server |
# Sample session: a Multipass practice server with an extra disk for the storage lessons
$ multipass launch 24.04 --name lab --cpus 2 --memory 2G --disk 20G
Launched: lab
$ multipass exec lab -- bash -c 'truncate -s 2G /tmp/disk1.img && sudo losetup -fP --show /tmp/disk1.img'
/dev/loop5
$ multipass stop lab && multipass snapshot lab --name clean # snapshots need a stopped instance
Snapshot taken: lab.clean
$ multipass start labA loop device (a file pretending to be a disk) is enough for the LVM, filesystem and quota lessons. A snapshot taken before each experiment lets you undo a broken firewall or fstab in seconds; that is exactly the safety net you will not have on a production server, so get used to thinking "how do I undo this?" before you press Enter.
Ground rules for real servers
- Keep a second session open while you change SSH, sudo, firewall or network settings. If the change locks you out, the open session is your way back.
- Validate before reload:
sshd -t,visudo -c,nginx -t,systemd-analyze verify,caddy validate. Each section shows the command for its daemon. - Know the console: cloud providers offer a serial or web console that works without SSH. Find it before you need it.
- Write it down: every change you make by hand should end up in a script, an Ansible role or an image. The Field Notes come back to this.
Test yourself
Why can't the course's sessions run systemctl start nginx?
- nginx isn't installed
- The sandbox has no systemd running as PID 1 (and no root), so there is no service manager to talk to
- systemctl only works on Red Hat
- Port 80 is blocked by the firewall
You are about to change sshd_config on a remote server. What protects you best against locking yourself out?
- Rebooting afterwards
- Running
sshd -tand keeping a second SSH session open until a new login works - Using a longer password
- Editing the file with sudoedit
What is a loop device useful for in a practice VM?
- Faster networking
- Pretending a file is a block device, so you can practise partitions, LVM and filesystems without a spare disk
- Running containers
- Looping shell scripts