Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The XDG specification talks about the XDG_CONFIG_HOME variable, but does not specify where it should be defined. Should we define it in /etc/X11/Xsession, or is it the window manager's config file that needs to define this?

I tried declaring it in /etc/environment as


but that didn't work, as it seems that $HOME is not defined when /etc/environment is parsed.

The only documentation I could find online was for Gentoo, where it was declared in /etc/env.d/90xsession

I'm using Ubuntu. What would be the general solution for Debian based distros?

share|improve this question
up vote 7 down vote accepted

In Arch Linux, this is defined by /etc/profile, using a /etc/profile.d script. (I made a list of variables once.)

For Debian/Ubuntu, if there's a /etc/profile.d – create a similar script inside; if such a directory does not exist – edit /etc/profile itsef.

export XDG_CONFIG_HOME="$HOME/.config"

The /etc/environment file is parsed by pam_env, which treats it as simple name=value assignments. However, it also has /etc/security/pam_env.conf, which supports variable expansion and can be used for this purpose.

share|improve this answer
Thanks! That helped. – NOLFXceptMe Dec 8 '11 at 14:13
Gist is unavailable – hawk Nov 22 '13 at 12:32
It's not in /etc/profile in Arch anymore, and is only once mentioned from /etc/profile.d/ – phil pirozhkov Sep 21 '14 at 8:47
Link is dead ... – ManuelSchneid3r Jul 30 '15 at 11:39

You don't need to define it anywhere, unless you want to change the default.

XDG Base Directory Specification clearly says:

If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

So it is redundant to define it to the default value. All compliant applications will already use $HOME/.config

But, if you do want to change the default in a Debian/Ubuntu system, the best place is:

  • For a system-wide change, affecting all users: /etc/profile
  • For your user only: ~/.profile
share|improve this answer
downvoter is welcome to explain what's wrong with the answer, and preferably help improve it – MestreLion Sep 4 '14 at 15:02
This answer is perfectly fine, theoretically, but there is plenty software around, which is not XDG Base Directory Specification compliant and a quattuordecillion of bugs stemming from this ignorance. – ManuelSchneid3r Jul 30 '15 at 11:44
@ManuelSchneid3r Very true, but for such software setting XDG_CONFIG_HOME will make little difference anyway, if any. – MestreLion Aug 2 '15 at 9:19

I've found that it works best to set environment variables via PAM. For modern Linux distos, this means /etc/environment or $HOME/.pam_environment (see man pam_env). You can also set them in /etc/security/pam_env.conf using a special syntax. Here is how I set my XDG variables in /etc/security/pam_env.conf.


Previously I would set these variables in /etc/profile.d/ However, some applications start before that file is read. Switching to the PAM method solved the issue for multiple applications that behaved this way.

share|improve this answer

Your Answer


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.