Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My incredibly tech smart girlfriend took control of the cockpit and closed (like in close arrow) my virtual machine running Ubuntu 12.10. When I restarted, my 'Documents' folder in 'Home' was missing.

How do I recover it?

Thank you

share|improve this question

2 Answers 2

Ok, found it. :

To create a new Documents folder

Open home folder > right click > new folder. Name it Documents

If the icon is incorrect then right click on the new Documents folder > properties. Click on the folder icon, this will bring up a select custom icon window.

Browse to File System > usr > share > icons > Humanity > places > 48 & select the 1st folder_documents.svg. This should restore the icon to your Downloads folder

Then gedit ~/.config/user-dirs.dirs or browse to file. You'll see this line -

XDG_DOCUMENTS_DIR="$HOME/"

edit it to this & save. Then log out/in

XDG_DOCUMENTS_DIR="$HOME/Documents"
share|improve this answer

How does this work?

The "special" directories in home (e.g. Documents, Music, etc.) are updated early in the login process by a program called xdg-user-dirs-update. If $XDG_CONFIG_HOME/user-dirs.dir (by default this is the same as ~/.config/user-dirs.dir) is present it uses this to set the directories. The content of this file should look something like this:

# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/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="$HOME/Videos"

Why did it disappear?

Within a user session, if one of these directories is deleted and recreated it will be picked up automatically. However, if you remove the target location of $XDG_DOCUMENTS_DIR (like in this question) and reboot (or, presumably, logout), the program will assume you don't want to use it any more and reset the target to "$HOME/", effectively disabling it.

How do I get it back?

Simply re-setting the relevant value back to your chosen location in this file should return everything back to normal.

In this case, that means using your text editor of choice to change

XDG_DOCUMENTS_DIR="$HOME/"

to

XDG_DOCUMENTS_DIR="$HOME/Documents"

Of course, the Documents/ directory (or whatever you choose) should be present if you don't want to go through this process again ;) The change should be picked up by the file manager as soon as you open a new window, there's no need to restart or logout (it doesn't appear to be picked up straight away by the Unity launcher, though).

Alternatively, you can use the command line:

$ xdg-user-dirs-update --set DOCUMENTS "$HOME/Documents"

Just for completeness, you can fetch the PATH for a particular "special" location with:

$ xdg-user-dir DOCUMENTS

Enter man xdg-user-dir for the list of XDG user dir names, though they should be obvious from the file content pasted above.

References

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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