X without Display Manager

Usually, the X11 session is started by a display manager. However, when running a single-user system you may find display managers an unnecessary waste of resources. Fortunately, you can start X11 session without a display manager.

Using startx
The standard X11 distribution contains startx, a small script which can be used to start X11 session from a terminal (it's installed by ).

In order to start X11 this way, type in:

This will start the X11 server with default options and try to find an X11 session (e.g. a desktop environment) to start.

If you'd like to specify the session (program to start) yourself, you can do so as an argument to startx:

You can also pass X11 server options, by preceding them with a double dash:

Using a dedicated session runner
Some of the desktop environments provide their own replacements for startx. For example, Xfce4 provides startxfce4:

Starting X11 on console login
To avoid having to type the startx command over and over again, you may decide that a login to a specific vt should start X11. One of the ways to achieve that is to put a code like the following into your shell's RC (e.g. ~/.bashrc):

The XDG_VTNR variables specifies the VT number. If you'd like to use another VT, adjust the number accordingly.

The additional DISPLAY check is necessary since the snippet will be executed on each new interactive shell. Since XDG_VTNR will be set to the same value in the shells started within the X11 session (e.g. terminals), it is necessary to prevent them from trying to start X11.

The exec command causes the login shell to be replaced by the X11 session. This means that the user won't be able to use the shell used to start X11 anymore, and whenever the X11 session terminates, user will be logged back out. If you'd prefer to remain being logged in into vt, remove the exec word.

Method 1
In order to obtain complete X11 autologin, you can use the getty/login autologin feature along with the fore-mentioned trick.

First, create a new service file like the following:

with username replaced by your username, and tty8 being the tty you want the X11-starting login to be performed on. It should be noted that this tty will be used for login & console output, and X11 can be started on any other tty.

Afterwards, add the fore-mentioned snippet to your bashrc (with the same vt specified), enable the service:

and voilà.

Method 2
In another way, you can use su and xinit for direct login in X.

Service example:

You can use startx rather than xinit.

Improving the DISPLAY+XDG_VTNR hack
In order to avoid relying on the DISPLAY+XDG_VTNR trick to determine whether to start X11, we can extend the two above approaches by using a dedicated environment variable to distinguish the specific shell where X11 is to be started.

First, create a dedicated login wrapper:

This causes the user to be logged in with START_X11=1 environment variable set. Then, tell getty to use that file instead of the default /bin/login:

Finally, modify bashrc (or equivalent) to use the variable rather than guessing:

Remember to unset the variable before starting X11 -- otherwise all the X11 terminals would have it set and try to spawn another X11 session.