Press "Enter" to skip to content

How to change default folders on Ubuntu

Ubuntu, just like any version of Windows comes with some predefined folders, like Documents, Downloads, Music, Pictures or Videos that are all pointing to locations inside the Home folder. I just find so easy to use them, because it helps me be a bit more organized and because it comes with custom icons, it is really easy to differentiate them. But I had a slight issue with them, because my Home folder is on an SSD drive with limited storage, I cannot use them to actually store large downloads or videos in them, so here’s how I changed the path of those shortcuts to point to folders created on my 500GB HDD.

The path configurations of the users’ special folders are stored in a simple text file in the HOME/.config folder, more precisely in the user-dirs.dirs file.

In the first step fire up a Console. By default it should open in your user’s home folder, but you may run the cd ~ command just to make sure you’re in the right folder. Run the pwd command, this should yield /home/your_username.

Go into the .config folder by running cd .config

Open the user-dirs.dirs folder in your favorite text editor. Make sure you use the sudo otherwise the file is opened as read-only and you won’t be able to save it.

Each line corresponds to a folder. To change a folder’s location, just change it’s corresponding line. My 500GB HDD is mounted in /storage, on which I have created the Downloads and Videos folders. Then I’ve simply changed the path of those two to point to the corresponding folders inside /storage instead to the folders relative to my home directory:

XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="/storage/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="/storage/Videos"

I’ve only changed these two folders, I don’t really care about the others, as they take up minimal space compared to all my downloads and action/dashcam videos, but feel free to change any folder you want. You will need to do a restart before the changes take effect though.

2 Comments

  1. Andras
    Andras July 17, 2017

    I think a symlink is an other good solution.

    Example:
    Copy/move your folder to the new location:
    mv $HOME/Downloads /media/mydata
    Symlink the new folder to the old location:
    ln -s /media/mydata/Downloads $HOME

    That’s it. Works on every distribution on every folder/file without any extra configuration 😉

    Have a nice day!

    • László Gazsi
      László Gazsi July 18, 2017

      Hmmm… why didn’t I try symlinking them from the beginning? It isn’t more difficult than editing the configs, but it’s much more elegant… Thank you Andras for the tip!

Leave a Reply

Your email address will not be published. Required fields are marked *