Where should the XDG_CONFIG_HOME variable be defined?

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

XDG_CONFIG_HOME="$HOME/.config"

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?


In Arch Linux, this is defined by /etc/profile, using a /etc/profile.d script.

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.


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