2

For some reasons, when an XDG user directory (i.e., Desktop, Downloads, Templates, Public, Documents, Music, Pictures, or Videos) is empty, it turns into a symbolic link after some time. Below is an example when it happens to Downloads.

toto@pc-toto:~$ ls -l
total 60K
drwxrwxr-x  3 toto toto 4.0K Aug 31 10:10  Desktop/
drwxr-xr-x  5 toto toto 4.0K Aug 11 13:52  Documents/
lrwxrwxrwx  1 toto toto   21 Aug 31 10:51  Downloads -> /home/toto/Downloads
drwxr-xr-x  7 toto toto 4.0K Aug  3 16:50  Music/
drwxr-xr-x 26 toto toto 4.0K Aug  3 16:53  Pictures/
drwx------ 11 toto toto 4.0K Aug  9 11:34  snap/
drwxr-xr-x  5 toto toto 4.0K Aug  3 16:55  Videos/
toto@pc-toto:~$

This started to happen a few days ago on Ubuntu 23.04. It has also been seen on Ubuntu 20.04: Home directories turned into symbolic links without telling me the reason.

The empty folders will turn into symbolic links in a matter of hours. I didn't find any reason for this.

EDIT: The problem is still going on after upgrading to Ubuntu 23.10.

Temporary solution

Delete the symbolic link and recreate the relevant directories.

toto@pc-toto:~$ rm Downloads 
rm: remove symbolic link 'Downloads'? y
toto@pc-toto:~$ mkdir Downloads
toto@pc-toto:~$ ls -l
total 64K
drwxrwxr-x  3 toto toto 4.0K Aug 31 10:10  Desktop/
drwxr-xr-x  5 toto toto 4.0K Aug 11 13:52  Documents/
drwxr-xr-x  2 toto toto 4.0K Aug 31 10:51  Downloads/
drwxr-xr-x  7 toto toto 4.0K Aug  3 16:50  Music/
drwxr-xr-x 26 toto toto 4.0K Aug  3 16:53  Pictures/
drwx------ 11 toto toto 4.0K Aug  9 11:34  snap/
drwxr-xr-x  5 toto toto 4.0K Aug  3 16:55  Videos/
toto@pc-toto:~$

Then, add a hidden file in each directories. This would prevent the directories to become empty and to turn into symbolic links.

toto@pc-toto:~$ cd Downloads 
toto@pc-toto:~/Downloads$ touch .empty_file
toto@pc-toto:~/Downloads$

Finally, edit the file ~/.config/user-dirs.dirs to put the right paths of XDG directories back. For example, replace XDG_DOWNLOAD_DIR="$HOME/" by XDG_DOWNLOAD_DIR="$HOME/Downloads". Note: Since the appearance of the symbolic links, this file won't be affected until you reboot.

TVG
  • 327

0 Answers0