LPIC 102 – Install and Configure X11 Server on Linux

Displaying text and Graphics on Linux distributions such as Debian, Ubuntu, CentOS, Arch, Gentoo, RHEL and other Unix-like Operating Systems screen, X Window System software is used to accomplish this task. The universal X client look and design is manipulated by desktop environments such as GNOME, Xfce and KDE, Window Manager i.e Tab Window Manager and Window maker.Modern Linux distros uses X.org version 11 that is X11 as their main X protocol. X client and X server communicates through X protocol. To be a successful System Administrator, you must understand X Window System architecture and its customary tools you will use to configure X.

In this guide, we are going to learn how to install and configure X11 on a Linux operating system.

Understanding X11  System Architecture

The drawing structure provided by X Window System on a display are two and three dimensional shapes and are divided into  client and server which are required elements on the same computer by graphical desktop during installation. A web browser, terminal and even a game are considered as client component’s form of applications. The input devices such as keyboards, mice and touch-pads are controlled by X Window System. The following is the X11 Architecture.

With the help of X Window System, multiple X clients which are from different computers but on the same network can bring out requests to one remote X server. So any user or System Admin can have access to graphical application remotely whether they are available or unavailable on their local system.

The graphical login to any system is issued by a display manager and the system can be a computer across a network or or a local computer. When the computer boots up, the display manger is initiated and it start an X server session for the validated users. The display manager also supervise X server making sure that it’s up and running. Display managers include SDDm, LightDm and GDM.

Any running X server has a display name for identification and it look like this:

hostname:displaynumber.screennumber

Where;

  • hostanme: is the name of the system displaying the application.
  • displaynumber: this refers to group of screens which are in use. It may be multiple screens in a workstation or single screen. A display number which start at 0 is assigned to each running X server session.
  • screennumber: its default number is 0 when single or many physical screens are set to display as one screen.

DISPLAY environment variable show the name of running X session.

$ echo $DISPLAY
:0

According to the above output, we obtain the following:

  • It shows that the X server running is on the local system.
  • We see that after the colon is 0, meaning that the X server is the 1st.
  • A screen number is not seen because only one logical screen is being used.

An application can be started by allocating the screen number  to the DISPLAY environment variable before launching that application. an example is as follows:

DISPLAY=:0.0 tmux &

The above command will start the tmux application in the screen 0.0 rather than 0.1 when both screens are in use.

Configuring X Server on Linux

We use xdpyinfo command to display the running X server information in a Linux system;

$ xdpyinfo | head -n 100
name of display:    :0
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    12009000
X.Org version: 1.20.9
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    7
supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 4, bits_per_pixel 8, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 15, bits_per_pixel 16, scanline_pad 32
    depth 16, bits_per_pixel 16, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    depth 32, bits_per_pixel 32, scanline_pad 32
keycode range:    minimum 8, maximum 255
focus:  window 0x1a00007, revert to PointerRoot
number of extensions:    28
    BIG-REQUESTS
    Composite
    DAMAGE
    DOUBLE-BUFFER
    DPMS
    DRI2
    GLX
    Generic Event Extension
    MIT-SCREEN-SAVER
    MIT-SHM
    Present
    RANDR
    RECORD
    RENDER
    SECURITY
    SHAPE
    SYNC
    VMWARE_CTRL
    X-Resource
    XC-MISC
    XFIXES
    XFree86-DGA
    XFree86-VidModeExtension
    XINERAMA
    XInputExtension
    XKEYBOARD
    XTEST
    XVideo
default screen number:    0
number of screens:    1

screen #0:
  dimensions:    1111x706 pixels (294x187 millimeters)
  resolution:    96x96 dots per inch
  depths (7):    24, 1, 4, 8, 15, 16, 32
  root window id:    0x3ac
  depth of root window:    24 planes
  number of colormaps:    minimum 1, maximum 1
  default colormap:    0x20
  default number of colormap cells:    256
  preallocated pixels:    black 0, white 16777215
  options:    backing-store WHEN MAPPED, save-unders NO
  largest cursor:    64x64
  current input event mask:    0x7a0057
    KeyPressMask             KeyReleaseMask           ButtonPressMask          
    EnterWindowMask          PointerMotionMask        StructureNotifyMask      
    SubstructureNotifyMask   SubstructureRedirectMask FocusChangeMask          
    PropertyChangeMask       
  number of visuals:    270
  default visual id:  0x21
  visual:
    visual id:    0x21
    class:    TrueColor
    depth:    24 planes
    available colormap entries:    256 per subfield
    red, green, blue masks:    0xff0000, 0xff00, 0xff
    significant bits in color specification:    8 bits
  visual:
    visual id:    0x22
    class:    DirectColor
    depth:    24 planes
    available colormap entries:    256 per subfield
    red, green, blue masks:    0xff0000, 0xff00, 0xff
    significant bits in color specification:    8 bits
  visual:
    visual id:    0x2a0
    class:    TrueColor
    depth:    24 planes
    available colormap entries:    256 per subfield
    red, green, blue masks:    0xff0000, 0xff00, 0xff
    significant bits in color specification:    8 bits
  visual:
    visual id:    0x2a1
    class:    TrueColor
    depth:    24 planes
    available colormap entries:    256 per subfield
    red, green, blue masks:    0xff0000, 0xff00, 0xff
    significant bits in color specification:    8 bits
  visual:

In the above output, we obtain the following information;

  • The X server version i.e version number: 11.0
  • Display name i.e name of display: :0
  • The number of extensions in the X server i.e number of extensions: 28, highlighted in red in the above output.
  • The default screen number i.e 0.
  • Number of screens i.e 1.

And many other relevant information from xdpyinfo command.

The X server configurations file are located in /usr/share/X11/xorg.conf.d/ directory, we can list the contents of this directory with ls -alh command:

$ ls -alh /usr/share/X11/xorg.conf.d/
total 28K
drwxr-xr-x 2 root root 4.0K May 24 11:04 .
drwxr-xr-x 5 root root 4.0K Dec  7  2020 ..
-rw-r--r-- 1 root root   92 Oct 22  2019 10-amdgpu.conf
-rw-r--r-- 1 root root 1.4K Apr  8 15:29 10-quirks.conf
-rw-r--r-- 1 root root   92 Oct 22  2019 10-radeon.conf
-rw-r--r-- 1 root root 1.4K Aug 13  2019 40-libinput.conf
-rw-r--r-- 1 root root 3.4K Mar 11  2020 70-wacom.conf

In /etc/X11, we can find xorg.conf file which is a user-specified. With cat command we can look at the contents of this file;

$ cat /etc/X11/xorg.conf
Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
	ModulePath   "/usr/lib/xorg/modules"
	FontPath     "/usr/share/fonts/X11/misc"
	FontPath     "/usr/share/fonts/X11/cyrillic"
	FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/Type1"
	FontPath     "/usr/share/fonts/X11/100dpi"
	FontPath     "/usr/share/fonts/X11/75dpi"
	FontPath     "built-ins"
EndSection

Section "Module"
	Load  "glx"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/input/mice"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "HWcursor"           	# [<bool>]
        #Option     "Xinerama"           	# [<bool>]
        #Option     "StaticXinerama"     	# <str>
        #Option     "GuiLayout"          	# <str>
        #Option     "AddDefaultMode"     	# [<bool>]
        #Option     "RenderAccel"        	# [<bool>]
        #Option     "DRI"                	# [<bool>]
        #Option     "DirectPresents"     	# [<bool>]
        #Option     "HWPresents"         	# [<bool>]
        #Option     "RenderCheck"        	# [<bool>]
	Identifier  "Card0"
	Driver      "vmware"
	BusID       "PCI:0:2:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection

The X server undergoes self configuration when it is started at runtime. In the above output of xorg.conf file we obtain the following sections:

ServerLayout: In this section, all inputs such as keyboards, mice and screens which are visible to the in interface are grouped:

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

InputDevice: This section is used in the configuration of mouse and keyboard.

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/input/mice"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Monitor: This section shows where the monitor is connected and it describe how it is used.

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Device: This is where the physical video card is described.

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "HWcursor"           	# [<bool>]
        #Option     "DirectPresents"     	# [<bool>]
        #Option     "HWPresents"         	# [<bool>]
        #Option     "RenderCheck"        	# [<bool>]
	Identifier  "Card0"
	Driver      "vmware"
	BusID       "PCI:0:2:0"
EndSection

Screen: This section combines Monitor and Device.

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection

Keyboard Configuration

In /usr/share/X11/xorg.conf.d directory, here we can find the keyboard configuration file called 40-libinput.conf but the name depends on your distribution, this file has a section for keyboard configuration;

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

You can change the above section in order to get keyboard of your choice.

Generaring Xorg Configuration File

You can create a permanent /etc/X11/xorg.conf file even though after system startup, X creates its own configuration.

Run the following command first:

$ sudo Xorg -configure
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE) 
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE) 
(EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.

We get an error that server already running. To avoid this error specify the DISPLAY as follows:

$ sudo Xorg :1 -configure
X.Org X Server 1.20.9
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.15.0-140-generic x86_64 Ubuntu
Current Operating System: Linux bett 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-73-generic root=UUID=03191270-7598-4535-8b9f-d79d4aacb321 ro quiet splash
Build Date: 08 April 2021  12:29:22PM
xorg-server 2:1.20.9-2ubuntu1.2~20.04.2 (For technical support please see http://www.ubuntu.com/support) 
Current version of pixman: 0.38.4
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.1.log", Time: Tue Jun  8 08:49:57 2021
List of video drivers:
	amdgpu
	ati
	intel
	nouveau
	qxl
	radeon
	vmware
	modesetting
	fbdev
	vesa
(++) Using config file: "/root/xorg.conf.new"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"


Xorg detected your mouse at device /dev/input/mice.
Please check your config if the mouse is still not
operational, as by default Xorg tries to autodetect
the protocol.

Your xorg.conf file is /root/xorg.conf.new

To test the server, run 'X -config /root/xorg.conf.new'

In the above output, the xorg.conf.new file has been created in /root directory. So you have to move this file to /etc/X11 directory and rename it as xorg.conf:

sudo mv /root/xorg.conf.new /etc/X11/xorg.conf

Managing Access to the X server

xhost

For X server access control, we use xhost program to add users, hostnames for those who are allowed to make connections to X server. It is also used to delete them when they are no longer wanted.

Syntax:

xhost [[+-]name …]

+ sign: means access is granted to everyone, even if they aren’t on the list.

$ xhost +
access control disabled, clients can connect from any host

-sign: means access is restricted to only those on the list.

$ xhost -
access control enabled, only authorized clients can connect

+name: The given name is added to the list allowed to connect to the X server.

$ xhost +bett
bett being added to access control list

-name: The given name is removed from the list of allowed to connect to the server.

$ xhost -bett
bett being removed from access control list

xauth

xauth is X authority file utility. With this program, the authorization information used in connecting to the X server is displayed and edited.

Syntax:

xauth [ -f authfile ] [ -vqibn ] [ command arg … ]

Awareness of Wayland

The Wayland project which was started in 2010 is still under development and it is a new display protocol developed to replace X Window System. Currently, modern Linux Distros are using it as their main display server. Wayland has Gtk+ and Qt toolkit which provide rendering rather than server running between client and kernel in X Window System. For rendering to take place, Linux kernel make request through the Wayland protocol. Wayland compositor receive the request from Wayland protocol which was forwarded by the kernel which then control window management, input and composition.

The applications that still uses X Window System there is XWayland that handles them, this is a X server running within Wayland client and helps in rendering contents in client windows within X server.

WAYLAND_DISPLAY environment variable is used in Wayland protocol. We can use the following command to check the system if it is using Wayland:

$ echo $WAYLAND_DISPLAY
wayland-0

The output above shows that the system display is running Wayland.

Conclusion

We are glad you have known how to how to install and configure X11 on Linux. Stay tuned for other LPIC 102 guides.

Similar Guides:

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

Object-oriented programming (OOP) is the very foundation of modern programming languages, such as Objective-C, C++, Java, C#, Visual Basic .NET, […]

On our today’s guide, we will focus on how to schedule jobs on Linux with cron and systemd timers. One […]

Every experienced System Administrator should have a knowledge of user and group management in a Linux system. Executing this tasks […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.