Friday, May 17, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 23889  / 1 Year ago, mon, march 13, 2023, 8:19:42
~/temp$ mkdir dir1
~/temp$ mkdir dir2
~/temp$ mkdir dir2/dir21
~/temp$ ln -s dir2/dir21 dir1/ln2dir21
~/temp$ mkdir dir1/ln2dir21/dir3
mkdir: cannot create directory ‘dir1/ln2dir21/dir3’: No such file or directory

What does the following command:


~/temp$ ln -s dir2/dir21 dir1/ln2dir21

create (there are no errors for the ln command)? The created link dir1/ln2dir21 is red and it's type is lrwxrwxrwx which seems to be a link. Then why can't create directory through that symbolic link?


More From » symbolic-link

 Answers
3

The dir1/ln2dir21 symbolic link you created is relative to dir1.



The correct command would be:



ln -s ../dir2/dir21 dir1/ln2dir21


As another test, if you go to dir1 and create dir2/dir21 you will see that the red indicator will go away:



cd dir1
mkdir -p dir2/dir21
ll


You will see ln2dir21 -> dir2/dir21/ in normal color (no red error color).


[#4256] Tuesday, March 14, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
exceeeelh

Total Points: 21
Total Questions: 109
Total Answers: 120

Location: Marshall Islands
Member since Wed, Jan 5, 2022
2 Years ago
;