$linuxjunkies
>

xdg-user-dir(1)

Get the path to XDG user directories like Desktop, Documents, Downloads, Music, Pictures, Public, Templates, and Videos.

UbuntuDebianFedoraArch

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

FlagWhat it does
DESKTOPGet path to the Desktop directory
DOCUMENTSGet path to the Documents directory
DOWNLOADGet path to the Downloads directory
MUSICGet path to the Music directory
PICTURESGet path to the Pictures directory
PUBLICSHAREGet path to the Public Share directory
TEMPLATESGet path to the Templates directory
VIDEOSGet path to the Videos directory

Examples

Print the path to the user's Desktop directory (typically /home/user/Desktop)

xdg-user-dir DESKTOP

Print the path to the user's Downloads directory

xdg-user-dir DOWNLOAD

Change 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-dir

List the contents of the Music directory

ls $(xdg-user-dir MUSIC)

Related commands