XDG user directories
User directories are a set of common user directories located within the
$HOME directory, including
Desktop. Identified by unique icons within a file manager, they will commonly be automatically sourced by numerous programs and applications. is a program that will automatically generate these directories. See the freedesktop.org website for further information.
Creating default directories
To create a full suite of localized default user directories within the
$HOME directory, enter the following command:
LC_ALL=C xdg-user-dirs-updatecan be used.
When executed, it will also automatically:
- Create a local
~/.config/user-dirs.dirsconfiguration file: used by applications to find and use home directories specific to an account.
- Create a global
/etc/xdg/user-dirs.defaultsconfiguration file: used by applications to find and use home directories generally.
- Create a local
~/.config/user-dirs.localeconfiguration file: used to set the language according to the locale in use.
Creating custom directories
Both the local
~/.config/user-dirs.dirs and global
/etc/xdg/user-dirs.defaults configuration files use the following format to point to user directories:
A complete configuration file may also contain multiple entries:
XDG_DESKTOP_DIR="$HOME/Desktop" XDG_DOWNLOAD_DIR="$HOME/Downloads" XDG_TEMPLATES_DIR="$HOME/Templates" XDG_PUBLICSHARE_DIR="$HOME/Public" XDG_DOCUMENTS_DIR="$HOME/Documents" XDG_MUSIC_DIR="$HOME/Music" XDG_PICTURES_DIR="$HOME/Pictures" XDG_VIDEOS_DIR="$HOME/Videos"
XDG_DOWNLOAD_DIR variable has been created called
~/.config/user-dirs.dirs has been edited accordingly:
When downloading files from a web-browser, the default folder used for downloading will now be
Internet. Alternatively, it is also possible to specify custom folders using the command line. The syntax of this command is:
$ xdg-user-dirs-update --set XDG_NAME path/to/custom_folder
For example, the following command will produce the same results as the above configuration file edit:
$ xdg-user-dirs-update --set DOWNLOAD ~/Internet
The names of the xdg templates are
Querying configured directories
Once set, any user directory can be viewed with
Templates directory, which of course corresponds to the
XDG_TEMPLATES_DIR variable in the local configuration file:
$ xdg-user-dir TEMPLATES