Search code examples
posixsymlink

cd to symbolic link in linux shows error


XXXXX:~/a/n1$ ln -s n1 n
XXXXX:~/a/n1$ ls
bin      doc  n  nc.tcsh  packages  scripts  support  VERSION
XXXXX:~/a/n1$ cd n
bash: cd: n: No such file or directory

I am creating a sym link to n1 which is n. Now when i do a cd in bash or shell i am not able to.

What is missing.


Solution

  • Making a symlink is done as ln -s target linkname.

    The target "n1" does not exists in your current directory, but the link will nevertheless been made, allbeit a dead link. When you create a subdirectory "n1" in the current directory (like mkdir n1), the link will no longer be dead.

    If you meant to make a symlink to the current directory ".", then the command is: ln -s . n. Note that this will make it recursive, making cd n/n/n/n/ possible.