xinit
Start an X server and initial client
SYNOPSIS
xinit [client] [options ...] -- [server] [display] [options ...]
Or, more commonly, just xinit
PARAMETERS
client
Specifies the path to the initial client program to be run (e.g., a window manager or desktop environment session). Defaults to xterm if not specified.
client options
Additional command-line arguments to pass directly to the client program.
--
A mandatory separator indicating the end of client arguments and the beginning of server arguments. All arguments after this separator are passed to the X server.
server
Specifies the path to the X server executable (e.g., Xorg). Defaults to X.
display
Specifies the display number for the X server (e.g., :0). Defaults to the next available display number.
server options
Additional command-line arguments to pass directly to the X server program.
DESCRIPTION
xinit is a low-level utility used to manually start the X Window System server and a first client program. It provides a flexible way to launch a custom X session, bypassing traditional display managers like GDM or SDDM. When invoked, xinit looks for two user-specific shell scripts in the home directory: ~/.xserverrc to define how the X server should be started, and ~/.xinitrc to specify the initial client applications (typically a window manager or desktop environment and other essential programs). If these files are not found, xinit defaults to starting the X server and an xterm client. It's often wrapped by the startx script for convenience, which provides a more user-friendly interface for common setups.
CAVEATS
xinit is a lower-level utility; startx(1) or display managers (like GDM, SDDM) are typically preferred for daily use.
Exiting the primary client application (e.g., xterm or your window manager) will usually terminate the X server started by xinit.
Proper configuration of ~/.xinitrc is crucial for a functional graphical session.
THE .XINITRC FILE
This file, located in the user's home directory (~/.xinitrc), is a shell script executed by xinit to start client applications. It commonly includes commands to:
- Set environment variables.
- Load X resources (e.g., xrdb).
- Start background processes (e.g., notification daemons, compositors).
- Launch the window manager or desktop environment session (this is typically the last command and should be an
exec
command so that when it exits, xinit also exits).
THE .XSERVERRC FILE
This optional file, located in the user's home directory (~/.xserverrc), is a shell script executed by xinit to determine how the X server itself should be started. It can be used to specify a particular X server executable or pass specific options to it. For example, it might contain exec Xorg -vt7
to start Xorg on virtual terminal 7. If this file does not exist, xinit defaults to starting the X server with default options.
HISTORY
xinit has been a fundamental component of the X Window System since its early development. It provides the most basic and direct method for starting an X server and an initial client, serving as the foundation upon which more sophisticated session management tools like display managers were built. Its continued relevance lies in its flexibility for custom setups and debugging, offering a direct interface for advanced users to control their X sessions.