4.6. Practical Lab: Preparing a Debian Workstation or Server

A new machine is not ready merely because the desktop appears. An administrator should be able to say what role the machine serves, which desktop and services were chosen, how administrative access works, which hardware was detected, whether the network and updates are healthy, and how to reach the machine if the graphical session fails. This lab records those facts on the example machine and produces a baseline that can be compared after a change. It uses only shell commands, text files in the workspace, and ordinary service checks.

4.6.1. Choosing a Role and Recording Installation Decisions

Choose the role before adding packages. A workstation needs a desktop, audio, printing, and user-facing applications. A server may need no display manager at all, but it needs remote access, a firewall policy, and a service-specific package set. A hybrid machine, such as a developer laptop that also runs a local database, needs both, with the desktop services kept from consuming the resources reserved for the server workload.

Role Typical desktop task Services to plan Update and access policy
Workstation GNOME, KDE Plasma, or Xfce Display manager, PipeWire, CUPS, Bluetooth, keyring, desktop firewall Regular user updates; automatic suspend and lock; local console recovery
Server No desktop task; ssh-server SSH, firewall, time synchronization, service-specific daemons Unattended security updates where appropriate; remote and console recovery
Hybrid One desktop task plus server packages Desktop services plus the server's daemons and storage Separate resource limits; documented ports; a careful update window

The installer's task selection is only one input. Record the decisions that will be hard to reconstruct later: the Debian release, the desktop task, the display manager, the session type, the network backend, and the printing and scanning stack. A small text record is enough. The following command writes one key=value line per decision to a file in the workspace; the redirection means it produces no terminal output:

$ printf '%s\n' 'role=workstation' 'desktop=xfce' 'display_manager=lightdm' 'session=x11' 'audio=pipewire' 'printing=cups' 'scanner=sane' 'network=NetworkManager' > /home/john/debian-handbook/desktop-baseline/installation-decisions.txt

Read the file back with a separate command:

$ cat /home/john/debian-handbook/desktop-baseline/installation-decisions.txt
role=workstation
desktop=xfce
display_manager=lightdm
session=x11
audio=pipewire
printing=cups
scanner=sane
network=NetworkManager

For a server role, the same record would omit desktop, display_manager, session, audio, printing, and scanner, or mark them intentionally absent; for a hybrid, it would record which desktop services are enabled and which server ports are exposed. The point is to make the next administrator's question answerable without guessing from the installed package list. On a real machine, keep this record with the build documentation or in an administrative directory that is included in backups, and do not store passwords, Wi-Fi keys, or private keys in it.

The session entry deserves one clarification: on this machine Xfce installed both an X11 session file and a Wayland session file (Section 4.1.2), but the recorded choice is x11 because that is the session the machine is configured and tested to use. Recording session=x11 states the intended default; it does not remove the Wayland file, and a user can still choose the other session at the login screen for a test.

4.6.2. Checking Accounts, Hardware, Network Access, and Updates

Baseline checks should be repeatable and read-only where possible. Start with the host identity:

$ hostnamectl
 Static hostname: trixie
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 05f8a682837b4296a896777273ecd659
         Boot ID: c057bdce14a04461beb04f3e8206b620
  Virtualization: kvm
Operating System: Debian GNU/Linux 13 (trixie)
          Kernel: Linux 6.12.86+deb13-amd64
    Architecture: x86-64
 Hardware Vendor: QEMU
  Hardware Model: Standard PC _i440FX + PIIX, 1996_
Firmware Version: 1.16.3-debian-1.16.3-2

Selected output; the pictograph on the chassis line and the firmware date and age lines are omitted. The Virtualization and hardware fields matter when interpreting later results: this machine is a KVM guest, so a missing sound card or Bluetooth radio is a property of the virtual hardware, not evidence of a Debian defect. On a physical machine the same fields identify the chassis and firmware.

Check the account and its identity sources. id shows the numeric user and group identifiers and supplementary groups, and getent passwd reads the account through NSS, so it would also reflect directory-service accounts if one were configured:

$ id
uid=1001(john) gid=1001(john) groups=1001(john),27(sudo)
$ getent passwd john
john:x:1001:1001::/home/john:/bin/bash

The sudo group membership is this machine's administrative access. A desktop user may additionally belong to groups such as audio, video, or lpadmin, depending on the packages and the distribution's policy; group membership is not a substitute for a working polkit or device ACL, so check the actual operation as well as the group list. Chapter 5 covers accounts and delegation.

Password status answers whether each account can authenticate with a password. An ordinary user may query their own status, and the elevated form queries any account:

$ passwd -S
john P 2026-11-18 0 99999 7 -1
$ sudo passwd -S root
root P 2026-05-19 0 99999 7 -1

P means a password is set and L would mean locked. A locked password does not prevent SSH key authentication, and a locked root password simply means su - is unavailable while sudo remains. The sudo policy listing shows exactly what this account may run:

$ sudo -l
Matching Defaults entries for john on trixie:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User john may run the following commands on trixie:
    (ALL : ALL) ALL
    (ALL) NOPASSWD: ALL

The first rule is the standard sudo group rule: john may run anything, with john's password. The second rule exists only on this example guest so that unattended captures do not stall on a password prompt; a standard installation shows the first rule alone and asks for the password on each elevated command. If your machine shows broader rules than the work justifies, tighten them with visudo as described in Chapter 5.

Hardware and capacity come next. The PCI listing with its drivers appears with lspci -k; the display, storage, and network entries on this machine are:

$ lspci -k | grep -A2 "VGA\|SCSI\|Ethernet"
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
    Subsystem: Red Hat, Inc. QEMU Virtual Machine
    Kernel driver in use: cirrus
00:03.0 SCSI storage controller: Red Hat, Inc. Virtio block device
    Subsystem: Red Hat, Inc. Device 0002
    Kernel driver in use: virtio-pci
00:05.0 Ethernet controller: Red Hat, Inc. Virtio network device
    Subsystem: Red Hat, Inc. Device 0001
    Kernel driver in use: virtio-pci

Selected output; the grep stage selects the three device families and two lines of context after each match. Every controller has a bound driver. On a physical machine this listing identifies the actual chipset, and a missing Kernel driver in use line marks a device the kernel recognized but could not bind - the starting point for the driver and firmware investigation in Chapter 7. Memory completes the capacity picture:

$ free -h
               total        used        free      shared  buff/cache   available
Mem:           967Mi       399Mi       199Mi       2.3Mi       539Mi       568Mi
Swap:             0B          0B          0B

About 1 GiB of RAM and no swap, on a single virtual CPU - the facts that explain why a full GNOME or KDE session is heavier here than on a workstation and why hibernation cannot work (Section 4.5.1). The storage view in Section 4.3.3 applies unchanged: one virtual disk, one ext4 partition, mounted as the root filesystem.

Network access has several independent parts: link state and addresses, routes, name resolution, and the services that depend on them. The routing snapshot in Section 4.5.4 is this machine's view: one default route through eth0 and the attached 192.168.121.0/24 subnet. Name resolution is a separate check, because a working route does not imply a working resolver. getent exercises the same lookup path the applications use:

$ getent hosts deb.debian.org
2a04:4e42:20::644 debian.map.fastlydns.net deb.debian.org
$ cat /etc/resolv.conf
nameserver 192.168.121.1

The name resolved, this time to an IPv6 address; answers vary by resolver and network. /etc/resolv.conf here points at the virtual network's gateway, and on a desktop this file is often generated by the network manager or a local resolver, so a successful getent is the better functional check. Chapter 17 covers resolution and its configuration owners.

Remote administration depends on the SSH service and its listener. A service can be active after a manual start but disabled for the next boot, so check both:

$ systemctl is-enabled ssh
enabled
$ systemctl is-active ssh
active
$ ss -ltn
State  Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0      4096       127.0.0.1:631       0.0.0.0:*
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*
LISTEN 0      4096           [::1]:631          [::]:*
LISTEN 0      128             [::]:22            [::]:*

Two services are listening: ssh on port 22 for both address families, and CUPS on port 631 restricted to loopback, matching the Listen localhost:631 from Section 4.4.2. A firewall may still block a port that is listening, so test from another host as well as locally. Chapter 20 covers SSH configuration and key management.

The local console is the recovery path when SSH or the graphical session fails:

$ systemctl is-active getty@tty1
active

On a workstation, also confirm that the console is physically reachable with Ctrl+Alt+F3 and that a user can log in; on a server, confirm serial or management-console access before relying on it.

Boot and privilege configuration should be parseable, not merely present. The GRUB configuration check and the sshd configuration test both succeed silently when the files parse:

$ sudo grub-script-check /boot/grub/grub.cfg
$ sudo sshd -t

grub-script-check does not execute the boot menu, and sshd -t does not restart the service. The sudoers files get the same treatment, with output listing every parsed file:

$ sudo visudo -c
/etc/sudoers: parsed OK
/etc/sudoers.d/README: parsed OK
/etc/sudoers.d/john: parsed OK
/etc/sudoers.d/vagrant: parsed OK

The last entry belongs to the example machine's separate management account; a typical workstation lists only the entries for its own users. visudo -c checks syntax only: a syntactically valid sudoers file can still grant too much or too little, so read the rules as well. A malformed sudoers file can lock an administrator out of sudo, which is why edits belong in visudo with a recovery path available.

Package state and failed services complete the baseline. apt list --upgradable names the packages with available updates; apt warns that its output is not a stable interface for scripts:

$ apt list --upgradable
Listing...

WARNING:  apt does not have a stable CLI interface. Use with caution in scripts.

The empty listing means no upgradable packages were found. A simulation gives the same answer with apt-get's script-stable interface, and its tail stage keeps the output to the summary:

$ apt-get -s upgrade | tail -5
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

The -s simulation does not change the system. On a machine with pending updates, the summary names how many packages would be upgraded, installed, or removed; read the full simulation before applying a large upgrade, as Chapter 6 describes.

$ systemctl --failed
  UNIT LOAD ACTIVE SUB DESCRIPTION

0 loaded units listed.

A clean result means no unit is currently in the failed state; it does not mean every service is healthy, because a service that is disabled or misconfigured may not be failed. Check the units that matter for the machine's role, and read their logs when they are not active.

Finally, capture a compact baseline before making a change. Save the following script in the workspace as baseline.sh; it prints the host name, the user, the addresses, the routes, the SSH service state, the boot target, and the CPU count:

#!/bin/sh
hostname
id -un
ip -brief address
ip route
systemctl is-active ssh
systemctl get-default
nproc

Make it executable and run it with its output redirected to a file, which produces no terminal output:

$ chmod +x /home/john/debian-handbook/desktop-baseline/baseline.sh
$ /home/john/debian-handbook/desktop-baseline/baseline.sh > /home/john/debian-handbook/desktop-baseline/baseline-before.txt

Read the file with a separate command:

$ cat /home/john/debian-handbook/desktop-baseline/baseline-before.txt
trixie
john
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0             UP             192.168.121.39/24 fe80::5054:ff:fe30:78ce/64
default via 192.168.121.1 dev eth0
192.168.121.0/24 dev eth0 proto kernel scope link src 192.168.121.39
active
graphical.target
1

Each line is a separate result, so the file is easy to read but not a structured format. A snapshot that another program will parse should use a stable format such as key=value with quoted values; the purpose here is a human-readable before/after comparison, not a machine-readable inventory.

4.6.3. Preparing Recovery Access and Repeating the Baseline Checks

Recovery access is a prerequisite, not an afterthought. At least one path must remain usable when the desktop, SSH, or the network fails:

Recovery path How it is reached What it depends on Check before relying on it
Local virtual console Ctrl+Alt+F3, log in at the text getty Keyboard, display, working getty, account credentials systemctl is-enabled getty@tty1; try a text login
SSH ssh user@host on port 22 Network path, sshd, host key, authentication systemctl is-enabled ssh; ss -ltn; connect from another host
Root or sudo sudo -i or su - from an authorized account Working sudo policy or root password, PAM sudo -n id -u; sudo -l
Boot menu and rescue GRUB menu, recovery mode, or installer rescue Boot media or boot loader, root filesystem, console grub-script-check; confirm the menu at a console
Live or installer media Boot external media, mount the root filesystem Media, firmware, console, storage drivers Boot the media and confirm the disk and console work

On the example machine, SSH, the getty service, and sudo were the paths exercised in the previous section. The machine has no interactive console or serial access in this environment, and the boot menu and live media were not booted, so those rows remain requirements to verify on hardware where they exist. A noninteractive sudo probe confirms whether elevated recovery works without a password prompt:

$ sudo -n id -u
0

The printed 0 is root's user ID, so unattended elevation succeeds here - because of the example guest's passwordless rule described in Section 4.6.2. On a standard installation sudo -n fails by design, and the interactive equivalent is sudo -v, which validates the cached credentials after asking for the password once. Record the results in the decisions file or the build documentation, and note which paths were actually verified rather than merely enabled.

Now make a benign change and repeat the baseline to practice the procedure. Switching the power profile to power-saver and back to balanced changes state twice without affecting the recorded fields; both commands are silent:

$ sudo powerprofilesctl set power-saver
$ sudo powerprofilesctl set balanced

Collect the same fields into a second file, again with no terminal output:

$ /home/john/debian-handbook/desktop-baseline/baseline.sh > /home/john/debian-handbook/desktop-baseline/baseline-after.txt

Compare the two files:

$ diff -u /home/john/debian-handbook/desktop-baseline/baseline-before.txt /home/john/debian-handbook/desktop-baseline/baseline-after.txt

The command produced no output and returned status 0. For diff, status 0 means the files are identical, status 1 means they differ and the differences are printed, and status 2 means an error such as a missing file. The identical result is a stronger check than reading the second file and assuming it looks the same. It compared only the selected fields, so it would not detect a change in a service, package, or file that was not included in the snapshot.

The baseline can be extended for a specific role. A workstation might add systemctl is-active lightdm, the default session type, the default sink, and the CUPS queue list. A server might add the listening sockets, the firewall state, and the service units for its workload. Keep the field list stable so later comparisons are meaningful; if a field is added, record that the older baseline lacks it rather than treating the difference as a regression.

Rerunning the baseline after an update, a driver change, or a network change answers a narrow question: did any of the recorded fields change? It does not prove that the desktop, printer, or application still works. Follow a changed field with a functional test: log in graphically, print a page, scan a document, play audio, or connect through SSH. The baseline is an index into the system, not a substitute for exercising the service.

For a machine that will be handed to another administrator, store the decision record, the baseline, and the recovery procedure together. Include the hostname, addresses, account policy, boot mode, storage layout, installed desktop task, and the location of backups. Do not include passwords or private keys. Review the record after hardware or network changes, and repeat the baseline before and after the change. A workstation that is understood in those terms is easier to repair than one whose configuration exists only in the memory of the person who installed it.