What does it mean when a symbolic link (symlink) is red in Ubuntu?
Solution 1
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).
Solution 2
~/temp$ mkdir dir1/ln2dir21/dir3
you can't create a directory in a directory that is inexistent use mkdir -p
ln -s dir2/dir21 dir1/ln2dir21
is not working, because you're a) linking to a file not a dirrectory and b) it should be a full path. https://stackoverflow.com/a/9104390
so it should be: ln -s ~/temp/dir2/dir21/ ./dir1/ln2dir21
and it should workl...
Related videos on Youtube
jw_
Updated on September 18, 2022Comments
-
jw_ over 1 year
~/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 linkdir1/ln2dir21
is red and it's type islrwxrwxrwx
which seems to be a link. Then why can't create directory through that symbolic link?-
guiverc over 4 yearsHave you tried reading the manual page? ie.
man ln
? -
guiverc over 4 yearsDoes this answer your question? Question about the symlink of the ln command
-
jw_ over 4 yearsI'v read them, but there are too much like form 1/2/3/4 so not very carefully...
-
FedKad over 4 years
dir1/ln2dir21
symbolic link is relative todir1
. The correct command would beln -s ../dir2/dir21 dir1/ln2dir21
. -
guiverc over 4 years
man ls
tells me "ln [OPTION]... [-T] TARGET LINK_NAME" ie. TARGET is first so that's the target of the command, LINK_NAME is second which is the link (-s tells it symbolic) created. SPACES are delimiters, ie. "dir2/dir21" is the TARGET and "dir1/ln2dir21" the LINK_NAME in format path/file (where file can be the name of a file or a directory (file contains more files; in posix/unix/linux everything is a file in a way) -
jw_ over 4 yearsFailure without any error message? ln should print an error message "symbol link not created, target not exists, <absolute target path>"
-
Jesse Nickles about 3 yearsSee also: stackoverflow.com/questions/37866313/…
-
-
jw_ over 4 yearsI'm linking to a file, not directory.