Configure X
The main GUI in Linux is the X Window System (The X Server). Few extra topics beyond basic X configuration:
- Fonts
- GUI login tools - Display Manager (e.g. GDM) - Control the graphical login
- Desktop Environments (e.g. Gnome)
- X for Remote Access
- Accessibility - AccessX (acessibility control panels)
Serving the GUI component
The windows manager communicates with the display server on behalf of the UI
- Desktop Environment (e.g. Gnome)
- Windows Manager (e.g. Mutter, Kwin, Muffin, Metacity)
- Display Server (e.g. X)
- Compositor: Arrange display elements within a window to create a screen image
1 -X Basic
X is Linux’s GUI system. X isn’t a single program.
Features for configuration: (As an example)
Mouse
Keyboard layout
Screen resolution
Video refresh rate
Display color depth
Video card - X provides drivers that control the video card
Most modern computers include video hardware on the motherboard
Both AMD & Nvidia drivers include Linux kernel drivers as a necessary component.
So if upgrade Linux kernel, need to reinstall drivers.
X Server options
- XFree86 - Open source. Basis for X11
- X11 - Open source
- Accelerated-X - Commercial license, from Xi Graphics (Improvement on compatibility with video cards)
Config Notes
- Cmdline Tools:
sudo Xorg -configure
(File location:/root/xorg.conf.new
) - Main config file:
/etc/X11/xorg.conf
- X Accessibility
- Magnifier (
kmag
) - Enlarges the area around the mouse cursor
- Magnifier (
Test X Config Changes
Boot Linux to text mode
- Redhat -
telinit 3
- Debian -
/etc/init.d/gdm stop
(Shut down Display Manager)
- Redhat -
Change config via command line
Start X server:
startx
📌Logout & Restore to GUI login mode
- Redhat -
telinit 5
- Debian -
/etc/init.d/gdm start
- Redhat -
Can also boot into Graphics mode, then kill the X server.
1
2
3
4
5# get X
ps aux | grep X
# kill by PID
kill [PID]
X Config Options
Edit config file: Identify the feature that’s not working, and focus on the section that controls this feature.
An incorrect config of the video card is likely to cause failures in starting X.
1 - Module
- Controls loading X server modules - drivers for specific features / hardware
- If X configuration works, don’t adjust
Module
manually
2 - InputDevice
(Keyboard + Mouse)
-
Identifier
- ser defined label, to use inServerLayout
section -
Driver
- keyboard drivers:kbd
,Keyboard
,evdev
3 - Monitor
-
ModelName
- user-defined name HorizSync
&VertRefresh
📌- Horizontal (kHz) & Vertical (Hz) refresh rates
- Together define monitor’s max resolution & refresh rate
Modeline
- Look through modeline to select a resolution
- X11 supports Data Display Channel (DDC) - Monitor can communicate max refresh rates & mode lines to the computer
4 - Device
(e.g. Video Card)
X sends data to monitor via video card - Video card also controls monitor resolution
Set device driver -
Driver "nv"
- Drivers location:
/usr/lib64/xorg/modules/drivers/xx_drv.o
- Nvidia -
nv
/nouveau
- AMD -
radeon
- Intel -
intel
- Drivers location:
Graphical video modes require some RAM on the video card (BIOS will reserve some system RAM)
Modern video cards ship with large RAM to support 3D acceleration
5 - Screen
- Combination of monitos + video cards
- Choose between
Display
subsections: add optionDefaultDepth
6 - ServerLayout
- Links all above components - Usually Screen & Keyboard & Mouse
- Multi-head display - multiple monitors combined to form one large desktop
X Display Info
xdpyinfo
- display info for all available extensions1
xdpyinfo -ext [name]
xwininfo
- window info- Colormap
- Bit Gravity State
Wayland Server
Wayland is a replacement of X Windows System
- Initial release was in 2009, now used by many desktop environments, e.g. Gnome Shell & KDE Plasma
- Wayland native applications won’t use X at all
- Fewer video card problems
Check if display server is Wayland
Method 1 - Check env var
1
echo $WAYLAND_DISPLAY
Method 2 - Use
loginctl
1
2
3
4
5# get GUI session number
loginctl
# show type (Type=Wayland)
loginctl show-session [session number] -p Type
Turn off Wayland
1 | # edit file: WaylandEnable=false |
More about Wayland
- Compositor: Weston
- Weston is a reference implementation - As a compistor requirements example
- For backward compatibility: XWayland
- Allows X-dependent applications to run on X server & display via Wayland session
If system running fine under X, but problems under Wayland
- Check graphics card
- Go to graphics card vendor’s website, check if the driver support Wayland
2 - X Fonts
Notes
- X’s core font system can be setup form the X config file (managed directly by X)
- Font server
- Deliver fonts via network protocols
- Integrate with X core fonts, but run as separate programs
- Most modern program are using a new font system - Xft (to replace X core fonts)
- Xft bypass the core font system to provide client-side fonts
Font Formats
- Bitmap fonts
- Each font must be optimized for display at a particular resolution
- Outline fonts (Scalable)
- Represent each character as a series of lines & curves in a high-resolution matrix
- Scaling is imperfect - Scalable fonts often look slightly worse than bitmap fonts
- Scaling takes more CPU time - But on modern CPU it’s not really an issue
- Font rendering
- Apple TrueType -
freetype
(.ttf
) - Adobe PostScript Type 1 -
type1
(.pfa
,.pfb
)
- Apple TrueType -
X Core Fonts
Font directory:
/usr/share/X11/fonts
Store fonts elsewhere to prevent wiping from upgrade:
/opt/fonts
,/usr/local/fonts
Create font file
1
2
3
4
5
6
7
8# create font.dir file for trutype
ttmkdir
# For type 1
typelinst
# Apply to both type1 & truetype
mkfontscale
3 - Display Manager
X’s GUI login system uses XDMCP server. It starts X & manages X display
X is a network-enabled GUI
- The login system uses a network login protocol - XDMCP (X Display Manager Control Protocol)
- For remote login - XDMCP server listens for connections from remote X server
- For local login - XDMCP starts the local X server
Common XDMCP servers (i.e. Display Managers)
- XDM - oldest
- MDM - recursive acronym. Derivative of GDM
- GDM - for Gnome
- KDM - for KDE
- LightDM - bare-bone display manager for lightweight desktop environments like Xfce
Select Display Manager
- Select via config file -
/etc/sysconfig
, setDISPLAYMANAGER=/bin/gdm
- Select via
systemd
startup script
Configure Display Manager
- XDM
- Main config file -
/etc/X11/xdm/xdm-config
- Control remote access -
/etc/X11/xdm/Xaccess
- Main config file -
- KDM
- File location -
/etc/X11/kdm
,/etc/kde/kdm
- Try searching KDM config files in
kdm
orkdebase
package - Expands on XDM - User can select session type when login
- Extra options -
kdmrc
file,[Xdmcp]
section is for network operations
- File location -
- GDM
- File location -
/etc/X11/gdm
- Set local options in
custom.conf
file - GDM settings tool -
gdmconfig
orgdmsetup
- File location -
4 - Desktop Environment
KDE Plasma
- Display Manager - SDDM (Simple Desktop DM)
- File Manager - Dolphin
- Windows Manager - Kwin
Gnome
- Display Manager - GDM
- File Manager - Gnome Files (Formerly: Nautilus)
- Windows Manager - Mutter
Cinnamon
Fork of Gnome 3
- Display Manager - LightDM
- File Manager - Nemo (Fork of Nautilus)
- Windows Manager - Muffin (Fork of Mutter)
Xfce
- Display Manager - LightDM
- File Manager - Thunar
- Windows Manager - Xfwm (utilize its own compositor manager)
More about Xfce
- Lightweight environment: Not much CPU & memory consumption compared to the above ones
- Developed in 1996, as extension of CDE (Unix Common Desktop Environment)
Use XForms graphical toolkit (Xfce) - Rewritten and no longer use codes from CDE / XForms, but remain to be lightweight
Other
Install MATE
1 | sudo tasksel install ubuntu-mate-desktop |
5 - Remote Access
📌 只有 X Server 的 client-server model 是反过来的:Remote X clients access your X server.
X Server
X Client-Server
- In most cases, X server & client are on the same computer
- By default, X server only responds to local access requsts (as security measure)
-
xhost
port:6000
to6063
(set firewall policy for connection to pass through) -
xauth
- add, remove & list remote hosts in X11 config file
Using Remote X Client
Access remote machine (
remote
) via machine (local
)
Use compute resource onremote
, while using GUI onlocal
1 | # local: connect to remote |
Tunneling X via SSH
X11 forwarding - Remote GUI interactions within a secure channel
Encrypting X connection with SSH
- Encryption might slow down X access - Enable SSH compression
- Preferred & Secured: Tunneling X via SSH
- Change SSH config (enable forwarding)
- Client -
/etc/ssh/ssh_config
. UseSSH -X
, setForwardX11 yes
- Server -
/etc/sh/sshd_config
, setX11Forwarding yes
- Client -
1 | ssh -X user@remote |
SSH can tunnel network connections: Carry another potocol via its own encrypted connection.
Never use SSH -Y
, because it treats remote connection as trusted, which imposes security risks.
VNC
Notes
- VNC - Virtual Network Computing
- VNC is a cross-platform protocol, uses the RFB protocol (Remote Frame Buffer)
- Allows client to send GUI commands (mouse clicks) to the server
- Server sends desktop frames back to client
- Ports
- Server port -
TCP 5900 + n
(display number, usually port5901
) - Java-enabled browser -
TCP 5800 + n
- Server port -
2 types of desktop UIs
- Persistent - Persist GUI session state. Only available via browser access
- Static - Does not save state. Always show the default desktop environment
Pros & Cons
- Desktop is available for multiple users
- VNC only handles mouse & keyboard input. Does not provide file / audio transfer
- No traffic encryption by itself
- Password stored in plaintext in server file
- Improvement of RealVNC
- Server
- Install -
tigervnc-server
- Control -
vncserver
,vncconfig
- Install -
- Client
- Install -
tigervnc
- Control -
vncviewer
- Install -
- Use SSH port forwarding for VNC server ports - Allow traffic via port
22
Remote Desktop
Xrdp
Alternative to VNC. Use RDP (Remote Desktop Protocol)
Standard RDP port -
TCP 3389
NX
- NX protocol, created by NoMachine in 2001
- Compress X11 data - Excellent response time even over low-bandwidth connections
- Faster than VNC-based connections
- SSH tunneling by default
- Support multiple simultaneous users via a single network port
SPICE (Simple Protocol for Independent Computing Environments)
- X.org version - Xspice
- Provide connections with KVM virual machines
- Client uses multiple data socket connections
- Consumes low amount of CPU
- Strong security
- Traffic encrypted using TLS
- Authentication - SASL (Simple Authentication and Security Layer), supports Keberos
Both VNC & SPICE provide remote desktop connections to KVM vrirtual machines.
Localization
timedatectl
- Manage time & date
localectl
- Manage locale
1 - Time Zone
Linux uses UTC (Coordinated Universal Time) by default
- Translate to local time (Not a plain text file, cannot directly edit)
- Debian -
/etc/timezone
- Redhat -
/etc/localtime
- Debian -
hwclock
- Set Hardware clock (RTC)
- Display internal BIOS / UEFI clock
- Provide access to hardware clock built into the physical server
Verify local time
tzselect
- determines timezone ✅date
- 3-letter TZ code (legacy command)1
2# Set time & date format
date MMDDhhmm[[CC]YY][.ss]
Change Time Zone
Tools -
tzsetup
,tzselect
,tzconfig
Create softlink from zonefile to
localtime
1
2
3
4
5# remove or rename original timezone
sudo mv /etc/timezone /timezone.bkup
# create softlink
sudo ln -s /usr/share/zoneinfo/US/Pacific /etc/timezone
Use timedatectl
1 | # show time & date |
Most Linux system use NTP (network Time Protocol) to sync time & date with centralized time server.
If use NTP, unable to alter time / date using date
or timedatectl
locally.
2 - Locale
Codeset / Charater set
ASCII (American Standard Code for Information Interchange), 7-bit
ISO-8859
Unicode - 3-byte code (24-bit) to represent every know character
UTF (Unicode Transformation Format)
Transform long unicode value to 1-byte (UTF-8) or 2-bye (UTF-16) codes- UTF-8 (8-bit) ✅ New standard
Adopt UTF-8 over ISO-8859: No need to specify a substandard
- UTF-8 (8-bit) ✅ New standard
Locale: Specify language, country & related info for customizing display
- Format -
lang_country.codeset
(e.g.en_US.UTF-8
)
Locale options
File location -
/usr/bin/locale
-
LC_PAPER
- paper size. e.g. US letter, or standard A4 -
LC_MEASUREMENT
- measuring units -
LC_ALL
- Master override (all previous settings)
-
1 | # Check available locale |
Change locale
Temporary - Export both in current shell
Permanent - Add both lines in
~/.bashrc
1 | # need both LC_ALL & LANG |
Use localectl
(systemd
is enabled)
1 | # show current setting |
Modify Text file codesets 📌
1 | # get encoding list |
Printing
Two major visual output tool on the computer: Monitor & Printer
1 - Linux Printing Architecture
The Linux print queue is managed by CUPS (Common Unix Printing System)
Linux printing is built around the concept of print queue
- Print queue directory -
/var/spool/cups
- Network-oriented: Can accept print jobs from both remote & local systems
PostScript & GhostScript
- PostScript - common printer language
- Printer driver - Between application & print queue
- Linux printer driver is part of GhostScript (translator for PostScript)
- Some mid / low-end printers does not directly support PostScript
- GhostScript takes PostScript input, and produces output in many different bitmap formats
- Large GhostScript output file: Store briefly on hard disk
- Fit Ghostcript into the print queue: Smart filter
2 - Network Printing
CUPS (act as both server & client)
- Main config file -
/etc/cups/cupsd.conf
- Daemon runs in the background, watching for print jobs to be submitted
- Client pass print jobs to other computers
- Application can query CUPS about printer’s capabilities
CUPS Utilities
- Access CUPS daemon in browser: At port 631 📌
- Authentication: root (username) & root password
Network Printers
IPP - Internet Printing Protocol
Windows: SMB / CIFS (Server Message Block / Common internet File System)
Linux Samba server - Enable file sharing between machines in a single network
Two ways of printing to Windows from Linux
GhostScript - Windows SMB is non-PostScript, need a local Linux smart filter & GhostScript driver
PostScript - Print to Windows SMB queue from Linux via Samba (use PostScript driver)
1
2# URI for SMB share
smb://username:password@SERVER/SHARE
3 - Commands
Legacy BSD commands
lpr
lpq
lprm
lpc
lpr
- Submit print jobs
1 | -P [queue] // specify queue name |
lpq
- Display info about print queue
1 | lpq -P myqueue |
lprm
- Remove print jobs
1 | # Get job ID |
lpc
- Control print queue
- Start, stop & reorder jobs within print queue
- Other commands to control the queue
-
cupsenable
- enable queue -
cupsdisable
- disable queue -
lpmove
- move job from one queue to anothe
-