LinuxCommandLibrary

startx

Start the X Window System

TLDR

Start an X session

$ startx
copy

Start an X session with a predefined depth value
$ startx -- -depth [value]
copy

Start an X session with a predefined dpi value
$ startx -- -dpi [value]
copy

Override the settings in the .xinitrc file and start a new X session
$ startx /[path/to/window_manager_or_desktop_environment]
copy

SYNOPSIS

startx [ [client] options ... ] [ -- [server] options ... ]

PARAMETERS

client
    Specifies the client program to execute (e.g., xterm, gnome-session). If omitted, startx attempts to find a default, typically an xterm or a session manager specified in .xinitrc.

options ...
    Additional options or arguments to be passed to the specified client program.

--
    A mandatory separator used to distinguish between options for the client program and options for the X server program. All arguments following this separator are considered server options.

server
    Specifies the X server program to execute (e.g., Xorg). If omitted, startx attempts to find a default X server executable on the system's path.

options ...
    Additional options or arguments to be passed to the X server program (e.g., display number like :1, or virtual terminal like vt7).

DESCRIPTION

The startx command is a shell script that provides a user-friendly interface for launching the X Window System. It acts as a wrapper around the lower-level xinit command, simplifying the process of starting an X session from the console. When invoked, startx first determines which X server to run (e.g., Xorg) and which client application to start (typically an xterm or a desktop environment like GNOME or KDE).

It handles tasks such as setting up the display number, configuring the virtual terminal, and executing the user's .xinitrc file located in their home directory. The .xinitrc file is crucial for customizing the X session, allowing users to define the window manager, desktop environment, and other applications to launch upon startup. If a user-specific .xinitrc is not found, startx falls back to a system-wide default configuration. While modern Linux distributions often use display managers (like GDM, LightDM, or SDDM) to provide graphical login screens, startx remains valuable for users who prefer to log in to a text console and then manually start their graphical environment, or for troubleshooting purposes.

CAVEATS

startx is primarily intended for starting an X session from a text console, not from a graphical login manager. Its proper functioning relies heavily on the correct configuration of user-specific (~/.xinitrc, ~/.xserverrc) and system-wide (/etc/X11/xinit/xinitrc, /etc/X11/xinit/xserverrc) configuration files. It is less common in modern Linux distributions which typically default to graphical display managers (like GDM, LightDM, or SDDM) for user logins, potentially leading to conflicts or unexpected behavior if used incorrectly in such environments. Ensure your display server and window manager are correctly installed and configured.

CONFIGURATION FILES

startx relies on several configuration files to determine the X server, client, and session settings:

  • ~/.xinitrc: This is the primary user-specific file. It's a shell script that defines what applications, window manager, and desktop environment should be started in the X session. If this file exists, startx executes it.
  • /etc/X11/xinit/xinitrc: The system-wide default xinitrc, used if ~/.xinitrc is not found.
  • ~/.xserverrc: An optional user-specific file that defines which X server executable to run and with what arguments.
  • /etc/X11/xinit/xserverrc: The system-wide default xserverrc, used if ~/.xserverrc is not found.

DEFAULT BEHAVIOR

If no client or server is specified on the command line, startx attempts to find reasonable defaults. Typically, it looks for an xterm as the client and Xorg (or a similarly named X server) as the server, searching through common executable paths. The actual behavior can be influenced by the contents of the .xinitrc and .xserverrc files, which often define the default window manager (e.g., twm) or desktop environment (e.g., gnome-session, startkde) to launch.

VIRTUAL TERMINALS (VTS)

On systems using Linux consoles, startx typically switches the user from the current text-based virtual terminal (e.g., tty1) to a new graphical virtual terminal (e.g., tty7). This allows the graphical X session to run independently on its own VT, while the original text console remains available. The specific VT can often be controlled via server options like vt7 passed to the X server.

HISTORY

startx has been a fundamental part of the X Window System since its early days. Developed to simplify the process of initiating a graphical session for users logging in via a text console, it emerged as a convenient wrapper around the more complex xinit command. Its design as a flexible shell script allowed for easy customization and adaptation across various Unix-like systems. While graphical display managers have become the default for most users over time, startx has maintained its relevance for specific use cases, such as minimal installations, embedded systems, or for users who prefer granular control over their X session startup.

SEE ALSO

xinit(1), X(7), xterm(1), xdm(1), gdm(8), lightdm(8), sddm(8)

Copied to clipboard