3

I am using Ubuntu desktop. I want to change default location of document folder of my user (let's take testuser) from local system (/home/testuser/Documents/) to window share (\server1\share_name) mounted on /mount/win_share_name/.

Can I do it? If yes, please guide me.

2 Answers 2

5

The way I do it is using the user-dirs.dirs file, an then making a symbolic link. I will explain for Ubuntu 20.04, but it should be much the same in 18.04.

Make Documents bookmark point to a different directory

  1. Go to your home directory, and if you can't see any hidden directories (like .config) press Ctrl + h to show them (and again to hide them once more when done)
  2. Go into .config and open user-dirs.dirs (any text editor will do, by default will open in gedit)
  3. Find the line XDG_DOCUMENTS_DIR="$HOME/Documents"
  4. Change this to the directory you wish, if within home still just replace the /Documents part with the path from home, in your case you will want something more like XDG_DOCUMENTS_DIR="/mount/win_share_name/" if it is permanently mounted there (see https://wiki.ubuntu.com/MountWindowsSharesPermanently for more detail on doing this)
  5. Save the file and close it, your documents location will change next time you log in

HINT: If you easily want to copy the path of your target directory, just go into it and use Ctrl + l to show the path in the top bar where you can select and copy it.

Create link to the new Documents directory in Home

Once you log out and back in, you will have a documents directory in your home directory that will be doing nothing, so you can delete it (if you have been using it before making this change, make sure you copy everything to the new location). However, you may instead want a Documents directory (technically a “symbolic link”) in Home that points to the new location.

Preparation for creating the link: In some versions of Ubuntu, you may have to enable the option to show Create Link in the right-click menu (see the next section for instructions).

Create the symbolic link (or “symlink”):

  1. Go to the directory you want to use as documents, right click on the directory, choose copy
  2. Go to your home directory, right click (in empty space, not on an item) and choose Create Link

Create Link context menu

You should now have Documents set up correctly in the side menu, etc., and have a link to the new Documents directory in your home directory.

Enable “Show action to create symbolic links”

By default in Ubuntu 20.04, Create Link will not show up in the right-click menu. To enable it, click on the 3 bar logo at the top right of the file manager (Nautilus) and choose Preferences.

Choose Preferences

Go to the Behaviour tab and tick the option of Show action to create symbolic link. You should now see create link in the context (right click) menu when a directory has been copied (it will not show up if, for instance, you copy some text and then right-click inside a window of the file manager).

Select option to show in menu

2

On 18.04 and later, open /home/[user]/.config/gtk-3.0/bookmarks in a text editor, locate the line that says

file:///home/testuser/Documents

and change that to

smb://server1/share_name Documents

If you don't see a directory .config in the user's directory it's because items starting with a . are hidden by default. In the file dialog, press Ctrl + h to see hidden items.

Make a backup of the file first, of course.

The user may need to log out and back in before this works.

2
  • I am not seeing any folder called config in the root directory
    – Todd Welch
    Jun 21, 2019 at 0:53
  • I edited the answer.
    – Jos
    Jun 21, 2019 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.