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.
1. Check the active display-manager service alias
2. Identify the actual service name (GDM, LightDM, or SDDM)
3. Check the default-display-manager file on Debian-based systems
4. Determine the current graphical target status
# Step 1: Check the display-manager service aliassystemctl status display-manager
# Step 2: Find what the alias points tosystemctl 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 targetsystemctl get-default
# Should show: graphical.target
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.
1. Check whether the session is X11 or Wayland
2. Identify the X display number and desktop session name
3. Check locale and timezone settings
4. List all XDG session variables
# 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.
1. View recent display manager log entries with journalctl
2. Look for any error or warning messages
3. Check the user session error log
4. Find when the last successful login occurred
# 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.
1. List all available locales on the system
2. Check the current system locale with localectl
3. List available timezones matching your region
4. Check NTP sync status and current system time
# 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).
1. Check the current default systemd target
2. Understand what multi-user.target vs graphical.target means
3. Learn the command to switch to text mode (do NOT run on a live GUI — for reference)
4. Practice switching to virtual consoles using keyboard shortcuts
# Step 1: Current default targetsystemctl get-default
# Expected: graphical.target (if GUI is running)# Step 2: Understand targetssystemctl 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.