CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
  • Week 1
    • 1.Operating Systems and Linux: What the Kernel Does
    • 2.Free Software and Distributions: The Ecosystem Built by Licenses
    • 3.Installation and Booting: From the Moment You Power On
    • 4.Filesystem Structure and File Types: Everything Is a File
    • 5.Week 1 Comprehensive Review: Time to See Through the Concepts
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
    • 1.Mail Services: The MTA, MDA, MUA and SMTP, POP3, IMAP Triangle
    • 2.File Transfer Services: FTP Active/Passive Modes and vsftpd
    • 3.The Standard for Remote Access: SSH, sshd_config, Key Authentication, and Port Forwarding
    • 4.Remote GUI: VNC and the Client-Server Reversal of the X Window System
    • 5.Week 10 Comprehensive Review: Tying Network Services Together on One Port Sheet
  • Week 11
  • Week 12
  • Week 13
  • Week 14
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 1/Week 10/Day 4

Based on the Linux Master 1 exam syllabus·Report an error

Linux Master 1· AssociateWeek 10 · Day 4~22 min read

Day 4 - Remote GUI: VNC and the Client-Server Reversal of the X Window System

📌 Key Takeaways

  • The client-server relationship in X Window is the exact opposite of common sense. The machine in front of the user, which has the screen, keyboard, and mouse, is the X server, and the application that requests drawing is the X client.
  • VNC port = 5900 + display number (: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.
  • Two access controls: xhost (per host/IP, coarse) vs xauth (magic cookie, per user, precise).
  • xhost + with no argument allows everyone and is extremely dangerous. A safe remote GUI is ssh -X (encrypted tunnel + automatic xauth).

Remote Desktop — VNC, Which Transmits the Whole Screen

  • VNC (Virtual Network Computing) : A screen-sharing technology that shows the remote computer's screen as-is on my screen and sends my keyboard and mouse input to the remote machine.
ComponentRole
VNC serverRuns 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 protocolThe protocol VNC uses to exchange screen and input
  • In VNC, a port is assigned per display number.
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. :1 is 5901 and :2 is 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.

The X Window System — The Foundation of the Linux GUI

  • The Linux graphical environment is a structure in which a desktop environment such as GNOME or KDE sits on top of the X Window System (X11).
  • What's unique about X: it abstracted "drawing" into a network protocol.
ComponentRole
X serverManages the hardware such as screen, keyboard, and mouse, and receives drawing requests and actually draws
X clientAn application (terminal, browser, etc.) that asks the X server "draw it like this"
Window managerManages windows: borders, moving, minimizing, etc. (a kind of client)
Display managerProvides the graphical login screen (gdm, lightdm)

Client-Server Reversal — The Most Important Concept

[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)
  • It is the exact opposite of common sense.
    • X server = the machine in front of the user that has the screen and input devices (hardware).
    • X client = an application, near or far, that requests "draw this window."

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.

The DISPLAY Environment Variable — Specifying Where to Draw

  • An X client knows which X server (which screen) to draw to through the 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.5

DISPLAY 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.

xhost and xauth — Access Control for the X Server

  • It would be a problem if anyone could pop windows up on my screen, so the X server has an access control mechanism.
  • You must distinguish the two methods.
ToolMethodDescription
xhostHost-basedAllows/blocks X server access per host (IP)
xauthCookie-basedPer-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 cookie

xhost + (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."

Try It Yourself — Bringing Up a Remote GUI with X Forwarding

# 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

Pre-Exam Checklist

  • VNC port = 5900 + display number (:1 → 5901)
  • X server = the machine in front of the user with the screen and input devices, X client = the application (reversal)
  • DISPLAY = the address of the screen to send the picture to (:0 local, host:0 remote)
  • xhost = per host, xauth = per magic cookie
  • xhost + (no argument) allows everything and is extremely dangerous
  • Safe remote GUI = ssh -X (X11 forwarding, automatic xauth)

📖 Glossary

  • VNC : A remote desktop technology that transmits the remote screen as-is, pixel by pixel, and sends input back.
  • RFB protocol : The protocol VNC uses to exchange the screen and input. Its own encryption is weak.
  • Display number : A screen identifier like :0 or :1. The VNC port is determined by adding 5900 to it.
  • X Window System (X11) : The foundation of the Linux GUI. It abstracted drawing into a network protocol.
  • X server : The side that manages the screen, keyboard, and mouse and "provides the drawing service." It's the machine in front of the user.
  • X client : An application that uses that service and requests "draw it like this." It's a client even when running remotely.
  • Window manager : A kind of X client in charge of window borders, moving, and minimizing.
  • Display manager : A program providing a graphical login screen, such as gdm or lightdm.
  • DISPLAY : The address of the screen to which an X client sends its picture. The format is host:display_number.screen_number.
  • xhost : Coarse control that opens and closes X access per host (IP). It permits every user on the same host.
  • xauth / MIT-MAGIC-COOKIE : A precise authentication method that permits only the specific user holding the cookie.
  • xhost + (no argument) : An extremely dangerous command that allows all hosts. It makes screen capture and keystroke interception possible.
  • X11 forwarding (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.

📝 Practice Questions

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)?

PreviousThe Standard for Remote Access: SSH, sshd_config, Key Authentication, and Port ForwardingWeek 10 · Day 3Next Week 10 Comprehensive Review: Tying Network Services Together on One Port SheetWeek 10 · Day 5

Official references

  • Linux Master 1 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • Remote Desktop — VNC, Which Transmits the Whole Screen
  • The X Window System — The Foundation of the Linux GUI
  • Client-Server Reversal — The Most Important Concept
  • The DISPLAY Environment Variable — Specifying Where to Draw
  • xhost and xauth — Access Control for the X Server
  • Try It Yourself — Bringing Up a Remote GUI with X Forwarding
  • Pre-Exam Checklist
  • Glossary
  • Practice Questions