Friday, May 3, 2024
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 12564  / 3 Years ago, thu, october 7, 2021, 6:00:40

For example, I have a file a, and I do the followings.



ln -s a b
ln -s b c
ln -s c d


If I use readlink d, I will get c. So I have to run many times to get a.



Is there an easy way to get a?



Update:



If I want to locate the original file of /usr/bin/java, I have to do it many times to get /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java. The files and links are not in the same folder.


More From » symbolic-link

 Answers
5

Command for following chains of links is named nameiManPage. Examples:



$ touch a
$ ln -s a b
$ ln -s b c
$ ln -s c d
$ namei ./d
f: ./d
d .
l d -> c
l c -> b
l b -> a
- a
$ namei /usr/bin/java
f: /usr/bin/java
d /
d usr
d bin
l java -> /etc/alternatives/java
d /
d etc
d alternatives
l java -> /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java
d /
d usr
d lib
d jvm
d java-7-openjdk-i386
d jre
d bin
- java

[#28530] Friday, October 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bsorbedeldy

Total Points: 315
Total Questions: 110
Total Answers: 108

Location: Reunion
Member since Mon, Dec 28, 2020
3 Years ago
;