What is the typical real use case or application of symbolic/hard links in Linux?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping
--
Chapters
00:00 What Is The Typical Real Use Case Or Application Of Symbolic/Hard Links In Linux?
00:29 Answer 1 Score 3
00:47 Accepted Answer Score 12
01:41 Answer 3 Score 2
02:25 Answer 4 Score 3
03:02 Thank you
--
Full question
https://superuser.com/questions/364993/w...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux
#avk47
ACCEPTED ANSWER
Score 12
Any time that you want multiple names for the same thing, you need a link.
Shared libraries in Linux are named with their actual name, like in this example:
lrwxrwxrwx. 1 root root 16 Dec 2 15:24 /usr/lib64/libcurl.so -> libcurl.so.4.2.0
lrwxrwxrwx. 1 root root 16 Dec 2 15:04 /usr/lib64/libcurl.so.4 -> libcurl.so.4.2.0
-rwxr-xr-x. 1 root root 380864 Sep 19 07:04 /usr/lib64/libcurl.so.4.2.0
This is so that programs that want just any version of libcurl open libcurl.so. If they want version 4 they open libcurl.so.4. If they need the very specific version 4.2.0 they can open libcurl.so.4.2.0.
This is also used for programs like /usr/bin/java
. Java can be provided by many different sources. It might be the IcedTea OpenJDK. It might be the Sun JRE. Or it might be the IBM version. Using a symlink lets the system point to a default version, while keeping each version in its own directory.
ANSWER 2
Score 3
Links provide layer of redirection for a file name and its content. Regard this situation illustrated by Michael Jakl, in an article regarding use of rsync to mimic the behavior of Apple's Time Machine feature.
ANSWER 3
Score 3
Real world examples of hard link usage can be found in /bin
and other bin directories. Run the command ls -l /bin | grep -v ' 1 ' | sort
. This will give you a list of commands with multiple links. Some commands will act differently depending on the name you call them with. (Busybox is an extreme case.) Hard links must be on the same device and don't require additional disk space.
Symbolic links are used heavily in /etc
. It enables files located in other places in the hierarchy to be used without duplication. Symbolic links can cross device boundaries, but require additional disk space for the pointer.
ANSWER 4
Score 2
There are several uses of symbolic links in Linux, or *nix systems in general. For example, when you want to move the physical file location without breaking the existing or common "well-known" references, you may want to create a symbolic link at the old location. This is useful when you try to upgrade a commonly used tool with a private version, for whatever reason. Some utilities, such as busybox, uses a common binary to serve several needs. In certain Linux distributions, such as OpenWRT, the /bin/bash, /bin/ls, /bin/mv, etc. are all links to /bin/busybox. This binary is capable to behave differently based on the argv[0]
used.