Skip to content
Search

Startx

lastmod 2020-09-06created 2020-09-054 edits

The startx script is a front end to xinit(1).

Security notes

By default Xorg is configured to act as an X server. This can be dangerous since X uses unencrypted TCP connections and listens for X clients.

$ startx -- -nolisten tcp

How to use

Now try running startx to start the xserver. startx is a script that runs an xsession. Through this script, the xserver starts and graphical programs are launched on top of it. It decides which programs to run using the following procedure:

  • If a .xinitrc file exists in your home directory, it runs the commands listed in that file.
  • If that file does not exist, it reads the value of the XSESSION variable from /etc/env.d/90xsession and runs the corresponding session. The XSESSION values are in /etc/X11/Sessions/. To set a system-wide default session, run the following command:
$ echo XSESSION="Xfce4" > /etc/env.d/90xsession

This creates the 90xsession file and sets the default X session to Xfce. Don't forget to run env-update after changing the 90xsession setting.

$ startx

If you have not installed a window manager yet, you will only see a black screen. Since that may also mean something is wrong, it is a good idea to emerge twm and xterm purely for testing X.

Once the two programs are installed, run startx again. A few xterm windows should appear, which easily confirms that the xserver is working properly.

A session (the program to start) can be given as an argument to startx:

$ startx /usr/bin/startfluxbox

You can also pass X11 server options after two dashes:

$ startx -- vt7

See also

author Zer0 sitemap