What is xdg_config_home
Last updated: April 1, 2026
Key Facts
- XDG_CONFIG_HOME defines the base directory for user configuration files on Linux and Unix systems
- The default value is ~/.config (the .config folder in the user's home directory) when the variable is not set
- It is part of the XDG Base Directory specification established by freedesktop.org
- Applications should store configuration files in subdirectories named after the application within XDG_CONFIG_HOME
- This standardization allows users to manage and backup configuration files more easily across different applications
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
- Organization: Configuration files are centralized in one location rather than scattered throughout the home directory
- Backup and Migration: Users can easily backup or migrate configuration by copying the .config directory
- Consistency: Developers follow a common standard, making the system more predictable
- Management: Tools can be written to manage or clean up configurations consistently
- Cross-Platform: Similar implementations exist on other systems, improving portability
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.
More What Is in Daily Life
Also in Daily Life
More "What Is" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- XDG Base Directory SpecificationCC0-1.0
- Wikipedia - XDG Base DirectoryCC-BY-SA-4.0