What is xdg_config_home

Last updated: April 1, 2026

Quick Answer: XDG_CONFIG_HOME is an environment variable that specifies the base directory where applications store user configuration files. It defaults to ~/.config if not explicitly set and is part of the XDG Base Directory specification for standardizing file locations.

Key Facts

Overview

XDG_CONFIG_HOME is an environment variable that establishes a standard location for user configuration files on Linux and Unix systems. Defined by the XDG Base Directory specification, it provides a consistent approach for applications to store their settings and preferences, moving away from the historical practice of scattering configuration files throughout the home directory.

Default Location

If XDG_CONFIG_HOME is not explicitly set in the environment, applications should default to ~/.config as the configuration base directory. This means configuration files would be stored in a hidden .config folder within the user's home directory. Many modern applications follow this convention even on systems that don't explicitly set the variable.

Directory Structure

Applications are expected to organize their configuration files within subdirectories named after the application. For example, the GNOME Terminal application stores its configuration in ~/.config/gnome-terminal/, while the Firefox browser uses ~/.config/firefox/. This hierarchical structure keeps the configuration directory organized and prevents file name conflicts between different applications.

Advantages of XDG Standardization

Usage and Implementation

When developing applications, developers should check for the XDG_CONFIG_HOME environment variable and use it as the base path for configuration files. If the variable is not set, the application should default to ~/.config. This ensures compliance with the XDG specification and provides users with a familiar, organized file structure.

Related XDG Variables

XDG_CONFIG_HOME is part of a broader set of XDG Base Directory variables. XDG_DATA_HOME specifies where application data should be stored, XDG_CACHE_HOME defines the cache directory, and XDG_RUNTIME_DIR specifies runtime file locations. Together, these variables create a comprehensive standard for organizing user-specific files.

Related Questions

What is the difference between XDG_CONFIG_HOME and XDG_DATA_HOME?

XDG_CONFIG_HOME stores user-editable configuration and settings files, while XDG_DATA_HOME stores application-generated data, cache, and resources. Config files are typically human-readable settings, while data files are application state and content.

How do you find an application's configuration files?

Look in ~/.config/[application-name]/ by default. You can also check the XDG_CONFIG_HOME environment variable by running 'echo $XDG_CONFIG_HOME' in the terminal to see the actual configured location.

Can you customize where configuration files are stored?

Yes, you can set the XDG_CONFIG_HOME environment variable to any directory you prefer. Add 'export XDG_CONFIG_HOME=/your/custom/path' to your shell configuration file.

Sources

  1. XDG Base Directory Specification CC0-1.0
  2. Wikipedia - XDG Base Directory CC-BY-SA-4.0