Based on the Linux Master 1 exam syllabusReport an error
:1 → 5901). It transmits the screen wholesale as pixels, and since its encryption is weak, it is paired with an SSH tunnel.DISPLAY decides "which screen to send the picture to" — :0 is local, host:0 is remote, and with ssh -X it is usually localhost:10.0.xhost + with no argument allows everyone and is extremely dangerous. A safe remote GUI is ssh -X (encrypted tunnel + automatic xauth).| Component | Role |
|---|---|
| VNC server | Runs on the remote (target) computer and transmits its own screen |
| VNC viewer (client) | Runs on the computer in front of the user, displaying and operating the remote screen |
| RFB protocol | The protocol VNC uses to exchange screen and input |
VNC default port = 5900 + display number
:0 → 5900
:1 → 5901
:2 → 5902# Server side: install and run the TigerVNC server
dnf install tigervnc-server
vncserver :1 # Start the server on display 1 (port 5901)
vncpasswd # Set the VNC connection password
vncserver -kill :1 # Stop the server
# Client side: connect with a viewer
vncviewer 192.168.1.10:1 # or 192.168.1.10:5901⚠️ Trap: The VNC port is 5900 + display number.
:1is 5901 and:2is 5902. A choice stating "display 1 is 5900" is wrong (that's :0). This +number calculation is the key.
VNC is a "send the whole screen" approach like RDP (Windows). Because it compresses and sends the screen's pixels, it brings over the entire desktop as-is, unlike X forwarding, which sends only individual windows. However, VNC itself has weak encryption, so in practice it is usually carried over an SSH tunnel for safe use.
The reason VNC is paired with an SSH tunnel is that the RFB protocol's encryption is poor. If you open a tunnel with ssh -L 5901:localhost:5901 user@host and connect with vncviewer localhost:5901, the pixel data passes through the SSH encrypted tunnel and becomes safe. "VNC + SSH tunnel" is the standard combination in practice.
| Component | Role |
|---|---|
| X server | Manages the hardware such as screen, keyboard, and mouse, and receives drawing requests and actually draws |
| X client | An application (terminal, browser, etc.) that asks the X server "draw it like this" |
| Window manager | Manages windows: borders, moving, minimizing, etc. (a kind of client) |
| Display manager | Provides the graphical login screen (gdm, lightdm) |
[Monitor and keyboard in front of the user = X server] ←─ drawing requests ─ [Application = X client]
(the side with the screen is the server) (the side asking for the picture is the client)Key distinction: Why is it reversed? Because the X server is "the side providing the drawing service," and the application is "the side using (the client of) that service." It stays faithful to the general principle that whoever provides the service is the server — you just need to understand that "the service provided = drawing the screen." "The side with the screen = X server" is the signal for the correct answer.
⚠️ Trap: A choice saying "the program run on the remote server is the X server" is wrong. Even when running remotely, the application is always the X client, and the screen in front of me where its picture is displayed is the X server. A choice that flips this reversal is the trap.
DISPLAY environment variable.DISPLAY format = host:display_number.screen_number
:0 → local display 0
:0.0 → monitor 0 of local display 0
192.168.1.5:0 → display 0 of remote host 192.168.1.5# Check the current DISPLAY
echo $DISPLAY
# :0
# Direct output to a remote X server (draw on the remote display)
export DISPLAY=192.168.1.5:0
xclock # Now a clock appears on the screen of 192.168.1.5DISPLAY is the address that tells an X client "which screen should I send that picture to." Specify :0 for local, and host:0 to put it on a remote screen. If you use SSH X11 forwarding (ssh -X), this DISPLAY is automatically set to a value like localhost:10.0 and is delivered safely through the tunnel.
Key distinction: If DISPLAY is :0 it is local, and if it is hostname:0 it is remote. In SSH X11 forwarding, a display in the 10s such as localhost:10.0 is usually assigned, because SSH creates a virtual X display at the end of the tunnel and connects to it. DISPLAY is the address of the screen to send the picture to.
| Tool | Method | Description |
|---|---|---|
| xhost | Host-based | Allows/blocks X server access per host (IP) |
| xauth | Cookie-based | Per-user authentication with a magic cookie (MIT-MAGIC-COOKIE) |
# xhost — per-host control
xhost +192.168.1.5 # Allow X access for this host
xhost -192.168.1.5 # Block this host
xhost + # Allow all hosts (dangerous! weak security)
xhost - # Return to default authentication
xhost # Show the current access list
# xauth — magic cookie-based control
xauth list # List the currently registered authentication cookies
xauth add ... # Add a cookiexhost + (a + with no argument) is an extremely dangerous command that allows X access from all hosts. Anyone can capture my screen or intercept keystrokes. It shows up in the exam as an example of a "security-risky command." Conversely, xhost - turns off host-based permission and returns to default authentication.
Key distinction: xhost is coarse control per host (IP), and xauth is precise control per user with a magic cookie. xhost permits every user on the same host, so its security is weak, while xauth permits only the specific user holding the cookie, so it is safer. That's why SSH X11 forwarding uses the xauth cookie method.
In practice, bringing up a GUI with the combination export DISPLAY=remote:0 + xhost + can lead to a security incident. That's why today, instead of plaintext X forwarding, the standard is ssh -X (or -Y when trusted), which handles the encrypted tunnel + xauth cookie automatically. Summarize it as "safe remote GUI = ssh -X."
# Bring up a remote program on my screen via SSH X11 forwarding
ssh -X alice@192.168.1.10
echo $DISPLAY # localhost:10.0 (set automatically by forwarding)
xclock # Runs remotely but is displayed on my screen
xeyes # Test another X client:0 local, host:0 remote)xhost + (no argument) allows everything and is extremely dangerousssh -X (X11 forwarding, automatic xauth):0 or :1. The VNC port is determined by adding 5900 to it.DISPLAY : The address of the screen to which an X client sends its picture. The format is host:display_number.screen_number.xhost + (no argument) : An extremely dangerous command that allows all hosts. It makes screen capture and keystroke interception possible.ssh -X) : A feature that displays a remote application's GUI on my screen through the SSH encrypted tunnel. It handles the xauth cookie automatically.Click a choice to reveal the answer and explanation.
Question 1
Which correctly describes the roles of the X server and X client in the X Window System?
Question 2
What TCP port is used by default when a VNC server is run on display :2?
Question 3
Which environment variable specifies the target X server (screen) to which an X client outputs its picture?
Question 4
Which of the following X access control commands is extremely risky for security and not recommended?
Question 5
Which remote access method transmits the entire desktop screen of a remote computer pixel by pixel so you can operate it as-is?
Question 6
Which correctly states the difference in X access control between xhost and xauth?
Question 7
Which correctly describes the behavior when a remote program is run using SSH X11 forwarding (ssh -X)?