Exam weight: 2 โ LPIC-1 v5, Exam 102
What You Need to Know
From the official LPIC-1 objectives:
- Understanding of the X11 architecture.
- Basic understanding and knowledge of the X Window configuration file.
- Overwrite specific aspects of Xorg configuration, such as keyboard layout.
- Understand the components of desktop environments, such as display managers and window managers.
- Manage access to the X server and display applications on remote X servers.
- Awareness of Wayland.
Key files, terms, and utilities: /etc/X11/xorg.conf, /etc/X11/xorg.conf.d/, ~/.xsession-errors, xhost, xauth, DISPLAY, X.
X Window System Architecture
The X Window System (also known as X11 or just X) is a software stack used to display text and graphics on a screen. It is divided into a client and a server:
- The X server controls the physical display and handles input devices (mouse, keyboard, trackpad). It draws what clients request.
- An X client is any graphical application โ a terminal emulator, a browser, a game. Each client informs the server about its window location and content.
The X protocol (X11) is the communication mechanism between client and server. In modern Linux distributions, the primary implementation is Xorg version 11.
X is network-capable: multiple X clients from different computers on a network can make drawing requests to a single remote X server. This allows running a graphical application on a remote system and displaying it locally.
The X Window System is modular โ newer features are added as extensions to the X server without changing the core X11 protocol. Examples of Xorg extension libraries: libXrandr, libXcursor, libX11, libxkbfile.
A display manager provides a graphical login screen. It launches after boot, starts an X server session for the authenticated user, and keeps the X server running. Common display managers: GDM, SDDM, LightDM.
The DISPLAY Variable
Each running X server instance has a display name to identify it:
hostname:displaynumber.screennumber
- hostname โ the system that will display the application; omitted for localhost.
- displaynumber โ identifies the collection of screens in use; starts at
0. - screennumber โ identifies an individual screen within the display; default is
0and can be omitted.
The display name of a running X session is stored in the DISPLAY environment variable:
$ echo $DISPLAY
:0
This output means:
- X server is on the local system (nothing to the left of the colon).
- First X server session (display
0). - Single logical screen (no screen number shown).
Multi-monitor examples:
- (A) Single monitor, single display
:0โ one screen. - (B) Two physical monitors configured as one logical screen
:0โ windows move freely between monitors. - (C) Two monitors as independent screens
:0.0and:0.1โ windows cannot be moved between them.
To start an application on a specific screen:
$ DISPLAY=:0.1 firefox &
X Server Configuration
The primary configuration file is /etc/X11/xorg.conf. On modern distributions, X auto-configures at runtime, so this file may not exist. The file is divided into sections, each starting with Section "name" and ending with EndSection.
InputDevice
Configures a specific keyboard or mouse model.
InputClass
Configures a class of devices (e.g. all keyboards). Typically placed in /etc/X11/xorg.conf.d/. Example /etc/X11/xorg.conf.d/00-keyboard.conf:
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "us"
Option "XkbModel" "pc105"
EndSection
XkbLayout sets the key layout (language, Dvorak, etc.). XkbModel defines the keyboard type. Layout files are in /usr/share/X11/xkb.
Monitor
Describes the physical monitor and its connection port:
Section "Monitor"
Identifier "DP2"
Option "Primary" "true"
EndSection
Device
Describes the video card, its kernel driver, and PCI location:
Section "Device"
Identifier "Device0"
Driver "i915"
BusID "PCI:0:2:0"
EndSection
Screen
Ties a Monitor and Device together:
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "DP2"
EndSection
ServerLayout
Groups all sections (screens, input devices) into one X Window System interface:
Section "ServerLayout"
Identifier "Layout-1"
Screen "Screen0" 0 0
InputDevice "mouse1" "CorePointer"
InputDevice "system-keyboard" "CoreKeyboard"
EndSection
Config file locations and priority:
/etc/X11/xorg.conf.d/โ user-specified drop-in files (parsed first)/usr/share/X11/xorg.conf.d/โ distribution-provided configs/etc/X11/xorg.confโ main config (parsed after.conf.d/)
Keyboard Layout
Session-only โ change layout for the current X session:
$ setxkbmap -model chromebook -layout "gr(polytonic)"
setxkbmap uses the X Keyboard Extension (XKB). The change lasts until the session ends.
Persistent โ write to /etc/X11/xorg.conf.d/00-keyboard.conf directly, or use localectl (systemd) which creates that file automatically:
$ localectl --no-convert set-x11-keymap "gr(polytonic)" chromebook
--no-convert prevents localectl from also modifying the console keymap.
xdpyinfo
xdpyinfo displays information about a running X server instance: display name, version, vendor, extensions, screen dimensions, and more.
$ xdpyinfo
name of display: :0
version number: 11.0
vendor string: The X.Org Foundation
...
number of extensions: 25
BIG-REQUESTS
Composite
DAMAGE
DRI3
GLX
RANDR
RENDER
SECURITY
SHAPE
XKEYBOARD
...
default screen number: 0
number of screens: 1
screen #0:
dimensions: 3840x1080 pixels (1016x286 millimeters)
resolution: 96x96 dots per inch
depths (7): 24, 1, 4, 8, 15, 16, 32
...
Creating a Basic Xorg Configuration File
Even though X auto-configures on modern systems, you can generate a permanent /etc/X11/xorg.conf:
$ sudo Xorg -configure
If an X session is already running, specify a different display:
$ sudo Xorg :1 -configure
This creates xorg.conf.new in the current directory, derived from detected hardware. Move it to its final location:
$ sudo mv xorg.conf.new /etc/X11/xorg.conf
On some distributions, X is a symbolic link to Xorg and can be used instead.
Man pages for further reference: xorg.conf(5), Xserver(1), X(1), Xorg(1).
Wayland
Wayland is the newer display protocol designed to replace X. Many modern distributions use it as the default display server. It is lighter on resources and has a smaller footprint.
Key differences from X:
- No separate server โ there is no X server instance between the client and the kernel.
- A client window works with its own rendering code (GTK+ 3, Qt 5, etc.) and sends rendering requests to the Linux kernel via the Wayland protocol.
- The Wayland compositor handles device input, window management, and composition (combines rendered elements into visual output).
Modern toolkits (GTK+ 3, Qt 5) support both X and Wayland. Applications still targeting X can run under XWayland โ a separate X server instance that runs inside a Wayland client.
The Wayland equivalent of DISPLAY is WAYLAND_DISPLAY:
$ echo $WAYLAND_DISPLAY
wayland-0
This variable is not set on systems running plain X.
Quick Reference
# Check current display
echo $DISPLAY # :0 (local, first session, single screen)
# lab01:0.2 (host lab01, display 0, third independent screen)
echo $WAYLAND_DISPLAY # wayland-0 (only set on Wayland systems)
# Run app on specific screen
DISPLAY=:0.1 firefox &
# Show X server info (extensions, screen size, version)
xdpyinfo
# Generate xorg.conf from detected hardware
sudo Xorg -configure # creates xorg.conf.new in CWD
sudo Xorg :1 -configure # use if X session is already running
sudo mv xorg.conf.new /etc/X11/xorg.conf
# Keyboard layout โ current session only (uses XKB extension)
setxkbmap -model pc105 -layout us
setxkbmap -model chromebook -layout "gr(polytonic)"
# Keyboard layout โ persistent (creates /etc/X11/xorg.conf.d/00-keyboard.conf)
localectl --no-convert set-x11-keymap us pc105
localectl --no-convert set-x11-keymap "gr(polytonic)" chromebook
# --no-convert: do not also change the console keymap
# Config file locations and parse order
# 1st: /etc/X11/xorg.conf.d/ (user drop-in files)
# 2nd: /usr/share/X11/xorg.conf.d/ (distro files)
# 3rd: /etc/X11/xorg.conf (main config)
# xorg.conf section structure
Section "InputDevice" # specific keyboard or mouse model
Section "InputClass" # class of devices (e.g. all keyboards)
Section "Monitor" # physical monitor and port
Section "Device" # video card, driver, BusID
Section "Screen" # ties Monitor + Device together
Section "ServerLayout" # ties all sections into one interface
# Related man pages
man xorg.conf # xorg.conf(5)
man Xserver # Xserver(1)
man Xorg # Xorg(1)
Exam Questions
- What is the format of the DISPLAY variable? โ
hostname:displaynumber.screennumber - What does
:0mean in DISPLAY? โ Local X server, first display session, single logical screen. - What does
lab01:0.2mean? โ Systemlab01, display0, third independent screen (index2). - How to run an application on the second independent screen? โ
DISPLAY=:0.1 app & - What command shows X server info including extensions and screen dimensions? โ
xdpyinfo - Which xorg.conf section configures a class of input devices (e.g. all keyboards)? โ
InputClass - Which section configures a specific keyboard or mouse model? โ
InputDevice - Which section ties
MonitorandDevicetogether? โScreen - Which section groups all sections into one interface? โ
ServerLayout - Where should user drop-in Xorg config files be placed? โ
/etc/X11/xorg.conf.d/ - Which config location is parsed first โ
xorg.conforxorg.conf.d/? โ/etc/X11/xorg.conf.d/is parsed first. - How to change keyboard layout for the current X session only? โ
setxkbmap -layout us - How to persistently set the X11 keyboard layout? โ
localectl --no-convert set-x11-keymap - What does
--no-convertdo inlocalectl? โ Prevents changing the console keymap at the same time. - What command generates a new
xorg.conffrom detected hardware? โsudo Xorg -configure - What file does
Xorg -configurecreate, and where? โxorg.conf.newin the current working directory. - What component is responsible for keeping the X server running after login? โ The display manager (GDM, SDDM, LightDM).
- What is XWayland? โ A separate X server that runs inside a Wayland client, allowing X-only apps to work under Wayland.
- What environment variable identifies the display on a Wayland system? โ
WAYLAND_DISPLAY - What Xorg libraries extend X server functionality? โ
libXrandr,libXcursor,libX11,libxkbfile.
Exercises
Exercise 1 โ Identifying Xorg Extensions
What command would you use to determine what Xorg extensions are available on a system?
Answer
$ xdpyinfo
xdpyinfo displays information about the running X server, including the full list of loaded extensions, the display name, server version, and screen properties.
Exercise 2 โ New Mouse Configuration
You have just received a brand new 10-button mouse that requires extra configuration. Without modifying the rest of the X server configuration, what directory would you use to create a new configuration file for this mouse, and what specific configuration section would be used?
Answer
Directory: /etc/X11/xorg.conf.d/
Section: InputDevice
The InputDevice section configures a specific hardware device. By placing the file in /etc/X11/xorg.conf.d/, you leave the main xorg.conf untouched while the drop-in is parsed first.
Exercise 3 โ What Keeps X Running?
What component of a Linux installation is responsible for keeping an X server running?
Answer
The display manager (e.g. GDM, SDDM, LightDM). It starts after boot, launches the X server session for the authenticated user, and keeps it running.
Exercise 4 โ Generating xorg.conf
What command line switch is used with the X command (or Xorg) to create a new xorg.conf configuration file?
Answer
-configure
$ sudo Xorg -configure
X is a symbolic link to Xorg on many distributions. The command creates xorg.conf.new in the current directory based on detected hardware. Move it to /etc/X11/xorg.conf to activate it.
Exercise 5 โ Reading the DISPLAY Variable
What would the contents of the DISPLAY environment variable be on a system named lab01 using a single display configuration, where the terminal is on the third independent screen?
Answer
lab01:0.2
lab01โ hostname0โ single display (displaynumber)2โ third independent screen (screennumber starts at 0)
Exercise 6 โ Persistent Keyboard Configuration
What command can be used to create a keyboard configuration file for use by the X Window System that persists after reboot?
Answer
$ localectl --no-convert set-x11-keymap us pc105
localectl (from systemd) automatically writes the configuration to /etc/X11/xorg.conf.d/00-keyboard.conf. The --no-convert flag prevents it from simultaneously updating the console keymap.
LPIC-1 Study Notes | Topic 106: User Interfaces and Desktops