What does it mean when a symbolic link (symlink) is red in Ubuntu?

14,026

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...

Share:
14,026

Related videos on Youtube

jw_
Author by

jw_

Updated on September 18, 2022

Comments

  • jw_
    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 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?

    • guiverc
      guiverc over 4 years
      Have you tried reading the manual page? ie. man ln ?
    • guiverc
      guiverc over 4 years
      Does this answer your question? Question about the symlink of the ln command
    • jw_
      jw_ over 4 years
      I'v read them, but there are too much like form 1/2/3/4 so not very carefully...
    • FedKad
      FedKad over 4 years
      dir1/ln2dir21 symbolic link is relative to dir1. The correct command would be ln -s ../dir2/dir21 dir1/ln2dir21.
    • guiverc
      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_
      jw_ over 4 years
      Failure without any error message? ln should print an error message "symbol link not created, target not exists, <absolute target path>"
    • Jesse Nickles
      Jesse Nickles about 3 years
  • jw_
    jw_ over 4 years
    I'm linking to a file, not directory.