XDG Base Directory

noun

say it: “EKS-DEE-JEE BAYS dih-REK-tuh-ree” /ˌɛksˌdiˈdʒi ˈbeɪs dɪˈrɛktəri/

A set of shared rules for where Linux apps keep their files in a home folder: settings in .config and data in .local/share.

What are the XDG Base Directory rules?

The XDG Base Directory rules say where an app keeps its files in your home folder: settings in ~/.config/APP and data in ~/.local/share/APP, whatever folder you run it from. A person can move those folders with XDG_CONFIG_HOME and XDG_DATA_HOME, so scripts use those when they're set.

data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/recipes"
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/recipes"
echo "$data_dir"     # /home/sam/.local/share/recipes
echo "$config_dir"   # /home/sam/.config/recipes

In a sentence

  • “git reads its settings from ~/.config/git, as the XDG Base Directory rules say.”
  • “Following the XDG Base Directory rules, recipes keeps its data in ~/.local/share/recipes.”

Level: Journeyman · More Unix terms at this level

Updated