Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What is the purpose of the .xsession file in the home folder? What should be put in there? The desktop environments don't use that file and for the X startup from the tty there is .xinitrc.

share|improve this question

4 Answers 4

up vote 14 down vote accepted

If you log in in text mode then start a GUI session with xinit or with the wrapper script startx, then xinit does the following things:

  • Start an X server (typically through the script /etc/X11/xinit/xserverrc).
  • Usually run some scripts in /etc/X11 (typically /etc/X11/xinit/xinitrc), depending on how it's set up.
  • Run ~/.xinitrc, if it exists. If it doesn't exist, run a default client (traditionally xterm).
  • Once ~/.xinitrc terminates, kill the X server.

If you log in in graphical mode on an X display manager (xdm, gdm, kdm, wdm, lightdm, …), traditionally, what is executed after you log in is some scripts in /etc/X11 then ~/.xsession.

~/.xsession has the role of ~/.profile and ~/.xinitrc combined: it's supposed to perform the initial startup of your session (e.g. define environment variables), then launch programs specific to the GUI (usually at least window manager).

Nowadays, most X display managers give you a choice of a session. Choosing a particular session launched a specific desktop environment, session manager, window manager. What is executed then is only that DE/SM/WM and whatever programs it chooses to start based on whatever configuration files it chooses to read. Many environments provide a “custom session” that reads the traditional ~/.xsession.

share|improve this answer

.xsession is the traditional startscript for the X11 environment. Nowadays with sessionmanagers like kdm it is not that much of a use anymore, but on a traditionaly set up system. This is what is run after starting X11 with startx.

share|improve this answer

I strongly recommend you to take a look in the book X Window system administrator's guide : for X version 11. Chapter 2 explains the purpose of .xsession and the whole configuration process for a sample setup. Also it's a nice refresher for the whole x-window related terminology (and i hope you don't get spooked :) ). You can get the book from

http://archive.org/details/xwindowsystemadm08muimiss

Although it's rather outdated you can find a lot of information of the underlying concepts that didn't change until today and it is very legible. Moreover it is really funny to take a look at what was top notch at those days.

share|improve this answer

X session startup can be complicated these days. A good place to start is the script /etc/X11/Xsession to see how things will get executed.

On my Debian/Ubuntu systems, the script /etc/X11/Xsession sets the variable USERXSESSION=$HOME/.xsession. Later, the script /etc/X11/Xsession.d/50x11-common_determine-startup looks for this script and uses it as the primary session, if allowed by system policy in /etc/X11/Xsession.options, and if no other session was requested by the display manager.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.