0

I was exploring the /bin directory. The /bin contains file of two different colours, which according to this answer correspond to:

  1. Green indicates executable file
  2. Sky blue indicates system link

In bash, I can execute files both of category, for example ping (executable) and cat (symbolic link).

Should symbolic links also be called executable? How do they differ from each other?

2

A symbolic link is a file that references another file. If /bin/cat on your system is a symbolic link, then running ls -l /bin/cat will show something similar to:

lrwxrwxrwx 1 root root       6 Dec 15  2018 /bin/cat -> some_other_file

When you use a symbolic link file, the kernel "follows" the link(s); you end up using the "real" file. If the "real" file is executable, then you can run that program via the symbolic link (as in your cat example).

Symbolic links can point to any other files (plain files, device file, directories, sockets, symbol links, etc); and can point to non-existent files.

You can use the ln command with the -s flag to create symbolic links.

4
  • I just saw, /bin/cat was referencing to 'coreutils' as u said but both of the files are in same directory. Then what is the use of creating symbolic link? – abhishek May 15 '20 at 23:43
  • What is the purpose of keeping two files on this case? – abhishek May 15 '20 at 23:45
  • 1
  • 1
    Example: Let's say you have java 8 and Java 11 installed in separate directories. You could make java a symbolic link pointing to one of the two. You could easily change the default Java version by modifying the target of the symbolic link. – Martin Konrad May 16 '20 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.