Where Is the .xinitrc File and What Runs It?
The .xinitrc script in your home folder (~/.xinitrc) controls what startx launches, from window managers to tray apps and keymap lines.
Last updated
The .xinitrc file is a shell script X runs when you type startx. It sets keymaps, launches helpers in the background, and ends with one exec line starting the window manager. That last line defines the session: when it exits, X exits.
Display managers bypass it entirely, which confuses people arriving from startx setups. One exec rule matters most: background everything else with ampersands and exec exactly one program last. A second exec never runs, and a missing one drops you straight back to console.
Where X11 stores this, by platform
~/.xinitrc
Your startx session script. One exec line last, helpers backgrounded with &. Ignored by GDM, SDDM, and LightDM sessions.
Frequently asked questions
How do I autostart apps with startx?
Append your programs with & before the final exec line, keeping exactly one exec as the last command. When that exec process exits, the X session ends. Test lines in a terminal first since a broken script kills the session instantly.
Does .xinitrc work with display managers?
No. Display managers like GDM, SDDM, and LightDM run session files instead and ignore .xinitrc by default. This file belongs to the startx workflow only. Check your DM docs for its own autostart mechanism.
Notice an outdated path? Let us know.