CHAPTER 7 — LAB

Display Managers Lab

Hands-on exercises investigating display managers, graphical session types, user environment configuration, and .Xsession troubleshooting on a Linux system.

Lab Exercises
1
Identifying the Active Display Manager
BEGINNER

Before you can manage a display manager, you need to know which one is running. Use systemd to investigate the active DM on your system.

# Step 1: Check the display-manager service alias systemctl status display-manager # Step 2: Find what the alias points to systemctl status display-manager | grep "Loaded:" # Look for the actual service file path (e.g., /lib/systemd/system/gdm.service) # Step 3: Check the Debian/Ubuntu default DM file cat /etc/X11/default-display-manager # Expected output: /usr/sbin/gdm3 or /usr/sbin/lightdm or /usr/bin/sddm # Step 4: Check graphical target systemctl get-default # Should show: graphical.target
SAMPLE OUTPUT (GDM system) /etc/X11/default-display-manager → /usr/sbin/gdm3 systemctl get-default → graphical.target
WHAT TO NOTE

The display-manager service is a systemd alias that always points to the configured DM. This means you can always use systemctl restart display-manager regardless of which DM is installed.

2
Checking Session Type and Environment Variables
BEGINNER

Investigate the current graphical session type and examine key environment variables that define your user environment.

# Step 1: Session type (x11 or wayland) echo $XDG_SESSION_TYPE # Step 2: Display number and desktop name echo $DISPLAY # X11 display (e.g., :0) echo $DESKTOP_SESSION # Desktop env (gnome, plasma, xfce) # Step 3: Locale and timezone locale # all locale variables timedatectl # current time/zone/NTP status # Step 4: All XDG variables env | grep XDG_
SAMPLE OUTPUT $XDG_SESSION_TYPE → x11 (or wayland) $DISPLAY → :0 (X11 sessions only — empty in Wayland) timedatectl → shows timezone, NTP sync status
X11 vs WAYLAND

If your session is Wayland, $DISPLAY may be empty or unset. Some applications check for $DISPLAY and fail to launch under Wayland. You can force X11 mode from the login screen (look for a gear icon) or set WAYLAND_DISPLAY="" to force X11 for specific apps.

3
Examining Display Manager Logs
INTERMEDIATE

Real troubleshooting skills require knowing where to look when things go wrong. Practice finding and reading DM logs.

# Step 1: View GDM logs (adjust for your DM) journalctl -u gdm --since today # For LightDM: journalctl -u lightdm --since today # Step 2: Filter for errors only journalctl -u gdm -p err --since today # Step 3: Check user session errors cat ~/.xsession-errors # if it exists cat ~/.xsession-errors 2>/dev/null | tail -30 # Step 4: Find last successful graphical login last | head -10 # recent login history who # currently logged in users and TTYs
EMPTY .XSESSION-ERRORS

If ~/.xsession-errors is empty or doesn't exist, the session started cleanly without errors. A large or growing file indicates session startup problems. The most recent errors are at the bottom of the file.

4
Configuring Locale and Timezone
INTERMEDIATE

Practice the administrative commands that configure language, keyboard, and time settings — all part of the user environment managed at display manager level.

# Step 1: List available locales (may be long — pipe to less) locale -a | grep en_ locale -a | wc -l # count total available locales # Step 2: Current locale settings localectl status # Shows: System Locale, VC Keymap, X11 Layout # Step 3: List timezones (filter to find yours) timedatectl list-timezones | grep America timedatectl list-timezones | grep Europe # Step 4: NTP and time status timedatectl # Look for: NTP service: active, System clock synchronized: yes
LAB NOTE — READ ONLY

This exercise uses read-only commands to explore settings without making changes. In a production system, only run sudo localectl set-locale or sudo timedatectl set-timezone when actually changing locale/timezone — these affect all users system-wide.

5
Switching Between Text and Graphical Targets
ADVANCED

Understand how systemd targets relate to display managers. Practice the commands for switching modes (important for server administration).

# Step 1: Current default target systemctl get-default # Expected: graphical.target (if GUI is running) # Step 2: Understand targets systemctl list-units --type=target # multi-user.target = runlevel 3 (no GUI) # graphical.target = runlevel 5 (with GUI, includes DM) # Step 3: Commands to change default target (REFERENCE ONLY) # sudo systemctl set-default multi-user.target # boot to text mode # sudo systemctl set-default graphical.target # restore GUI boot # Step 4: Virtual console switching (try this NOW — it is safe) # Press Ctrl+Alt+F2 to switch to tty2 (text console) # Press Ctrl+Alt+F7 (or F1) to return to graphical session # Some systems: Ctrl+Alt+F1 is the GUI, F2-F6 are text consoles who # see which TTYs are active
IMPORTANT — LAB SAFETY

Do NOT run systemctl set-default multi-user.target during this lab unless you understand how to recover the GUI. If you accidentally disable the display manager, run sudo systemctl start gdm (or lightdm/sddm) to restart it immediately without rebooting. The virtual console switching in Step 4 is completely safe.

Chapter 7 Lab Complete

Mark this lab complete to record your progress.

Lab progress saved.