xdg-user-dir command not found

In this troubleshooting guide we learn how to fix xdg-user-dir command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

xdg-user-dir: command not found

or when using sudo you get the following error message

sudo: xdg-user-dir: command not found

Solutions to xdg-user-dir: command not found

How To Fix xdg-user-dir: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu xdg-user-dir is provided by xdg-user-dirs package.

xdg-user-dirs is:

xdg-user-dirs is a tool to help manage “well known” user directories like the desktop folder and the music folder. It also handles localization (i.e. translation) of the filenames.

The way it works is that xdg-user-dirs-update is run very early in the login phase. This program reads a configuration file, and a set of default directories. It then creates localized versions of these directories in the users home directory and sets up a config file in $(XDG_CONFIG_HOME)/user-dirs.dirs (XDG_CONFIG_HOME defaults to ~/.config) that applications can read to find these directories.

To fix this problem, we can install more using the command below.

sudo apt-get -y install xdg-user-dirs

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install xdg-user-dirs.

sudo apt -y install xdg-user-dirs

Or if you have aptitude installed you can use the following command.

sudo aptitude install xdg-user-dirs

Summary

In this tutorial we learn how to fix xdg-user-dir command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.