Link to directory in bash

I'm using the ln command to create a symbolic link to a directory using bash, I went to the directory I wanted to make a link and used the following command:

ln -s C#/ ~/Projetos

This would create a link to ~/media/Projects/C# in the ~/Projetos folder.

But once I cd to my home, the folder is displayed in red color and I can't access it, what's happening here?

enter image description here


Solution 1:

You can check the link using ls -l (which is usually aliased to just ll). You will see something like this:

 user42@localhost$ ll ~/Projetos
 lrwxrwxrwx 1 user42 user42    3 Sep 26 19:48 Projetos -> C#/

this means, that using the path /home/user42/Projetos will be substituted with /home/user42/C#. This path does not exist.

You probably wanted to use either

  • a correct relative link like ln -s media/Projects/C# ~/Projetos
  • or an absolute link like in ln -s $PWD/C#/ ~/Projetos