IT lexicon › Infra & Ops › XDG Base Directory

XDG Base Directory

Infra & Ops På svenska → Updated: 2026-10-08
More info
Creator
Waldo Bastian
Released
2003
Owner
freedesktop.org
Spec
XDG Base Directory Specification

The specification that tries to get programs to keep configuration in ~/.config, data in ~/.local/share and cache in ~/.cache instead of scattering dotfiles across the home directory.

Waldo Bastian of KDE wrote the XDG Base Directory Specification in 2003 for freedesktop.org, around a simple idea: distinguish between the kinds of things a program saves. Settings belong under $XDG_CONFIG_HOME, by default ~/.config; data such as documents and plugins under $XDG_DATA_HOME, ~/.local/share; and anything that may be deleted at any time under $XDG_CACHE_HOME, ~/.cache. Later came $XDG_RUNTIME_DIR for sockets and locks that should die with the session, and in 2021 $XDG_STATE_HOME for history and logs that are neither configuration nor cache. System-wide counterparts live in $XDG_CONFIG_DIRS and $XDG_DATA_DIRS.

The point is that a backup can skip the cache, that configuration can be version-controlled as a single directory, and that ls -a in the home directory stops being a record of everything you ever installed. Desktop applications comply. The command-line veterans do so unevenly: Git has read ~/.config/git/config since 2012, while bash, ssh and GnuPG stick to their own dotfiles, so twenty years on the home directory is still a bit of both.

← Back to the lexicon