xdg-user-dir(1)
Get the path to XDG user directories like Desktop, Documents, Downloads, Music, Pictures, Public, Templates, and Videos.
Synopsis
xdg-user-dir [DIRECTORY_TYPE]Description
xdg-user-dir returns the full path to standard user directories as defined by the XDG Base Directory specification. It reads configuration from ~/.config/user-dirs.dirs or uses sensible defaults if that file doesn't exist. This allows applications to find user folders in a standardized way, even if the user has customized their directory structure.
If no DIRECTORY_TYPE is specified, all known directory types and their paths are printed. Directory types are case-insensitive and include DESKTOP, DOCUMENTS, DOWNLOAD, MUSIC, PICTURES, PUBLICSHARE, TEMPLATES, and VIDEOS.
Common options
| Flag | What it does |
|---|---|
DESKTOP | Get path to the Desktop directory |
DOCUMENTS | Get path to the Documents directory |
DOWNLOAD | Get path to the Downloads directory |
MUSIC | Get path to the Music directory |
PICTURES | Get path to the Pictures directory |
PUBLICSHARE | Get path to the Public Share directory |
TEMPLATES | Get path to the Templates directory |
VIDEOS | Get path to the Videos directory |
Examples
Print the path to the user's Desktop directory (typically /home/user/Desktop)
xdg-user-dir DESKTOPPrint the path to the user's Downloads directory
xdg-user-dir DOWNLOADChange to the Documents directory using command substitution
cd $(xdg-user-dir DOCUMENTS)Copy a file to the Pictures directory regardless of its custom location
cp file.txt $(xdg-user-dir PICTURES)/List all XDG user directory types and their paths
xdg-user-dirList the contents of the Music directory
ls $(xdg-user-dir MUSIC)