1

I am trying to make a symlink so all documents are on a different harddisk drive. I learned how to make a symlink and tried to create the desired symlink. this is the command I used in terminal:

ln -s /media/Schijf-2/Nel/Mijn Documenten/ ./home/nel/Documenten

However, I receive an error message:

ln: target '.home/username/Documenten' is not a directory

I found similar questions but I do not understand what I did wrong:

https://askubuntu.com/questions/465493/how-can-i-symlink-my-home-folder-from-another-drive

Create a symbolic link relative to the current directory

I tried to symlink my /home/<user>/Documenten directory to /media/Schijf-2/Nel/Mijn Documenten.

How can I succeed?

DutchArjo
  • 747

1 Answers1

1

There are a few problems with your command. You ran

ln -s /media/Schijf-2/Nel/Mijn Documenten/ ./home/nel/Documenten

This means "create a link called Documenten that points to /media/Schijf-2/Nel/Mijn Documenten/. Because of the space, the ln command was given Documenten and not ./home/nel/Documenten as a target. One of way of dealing with this is to quote the name (see here for more information):

ln -s /media/Schijf-2/Nel/"Mijn Documenten"/ ./home/nel/Documenten

The next issue is that apparently, there is already a file (and not a directory) called Documenten in your current directory which is why ln complains:

$ ls
file.txt
$ ln -s /tmp/ ./file.txt/
ln: target ‘./file.txt/’ is not a directory: Not a directory

So, to do what you actually wanted to do you will need to delete or rename the Documenten file:

$ mv Documenten Documenten.old

Then, run this command to create a link:

$ ln -s /media/Schijf-2/Nel/"Mijn Documenten"/ Documenten
terdon
  • 242,166
  • Can it be a problem that the /home//Documenten directory is a standard directory which is install automatically when a user is added? – DutchArjo Nov 16 '14 at 13:23
  • @DutchArjo I don't see why, no. It should make no difference as long as the directory (or a link to a directory) exists. – terdon Nov 16 '14 at 13:29
  • 1
    @DutchArjo - the proper way to relocate User Dirs (e.g. Documents, Pictures etc) is via the config file user-dirs.dirs, see here. – don_crissti Nov 18 '14 at 06:25
  • thanks. That is exactly what I wanted to do indeed! When you would post that as an answer, I can accept it... – DutchArjo Nov 18 '14 at 19:17
  • @terdon thanks, I now have succeeded in creating the symlink. I did not understand that I had to be in the /home directory to create a symlink to a different location there. I now have the symlink, and 'cd-in' into this symlink brings me exactly to the right location. – DutchArjo Nov 18 '14 at 19:24
  • @DutchArjo glad to be of help. What did you want me to post for you to accept this? Also, don_crissti has a point, it might be better to just change the location of the default directory as explained in the link he gave. – terdon Nov 18 '14 at 20:09
  • sorry, I see I forgot to mention @don_crissti in my comment. I wanted to use his suggestion and accept is as the used answer (I have used his suggestion now, although I ran into some other problem). Can I accept 2 answers? Yours becuase it learned me to create a proper symlink and don_crissti's answer to have the best way to relocate my default directory's. But I believe I should both the suggestions... (the symlink from documents, or downloads, because I have changed the xdg user dirs file now but the Downloads directory in Home does not refer to mijn /media/schijf-2 partition – DutchArjo Nov 18 '14 at 20:22
  • @DutchArjo no, you can only accept one but feel free to accept don_crissti's if he posts it. – terdon Nov 18 '14 at 20:42