System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

viewing the full path of the linked file

SOLVED
Go to solution
senthil_kumar_1
Super Advisor

viewing the full path of the linked file

Hi

I am using suse line 9. Some files are soft linked. i am not able to see the full path of the linked file.

Ex:

emdlagora02:/usr/x86_64-suse-linux/bin # ll
total 0
lrwxrwxrwx 1 root root 12 Dec 18 13:18 ar -> ../../bin/ar
lrwxrwxrwx 1 root root 12 Dec 18 13:18 as -> ../../bin/as
lrwxrwxrwx 1 root root 12 Dec 18 13:18 ld -> ../../bin/ld
lrwxrwxrwx 1 root root 12 Dec 18 13:18 nm -> ../../bin/nm
lrwxrwxrwx 1 root root 16 Dec 18 13:18 ranlib -> ../../bin/ranlib
lrwxrwxrwx 1 root root 15 Dec 18 13:18 strip -> ../../bin/strip


is it possible?
11 REPLIES
Ivan Ferreira
Honored Contributor

Re: viewing the full path of the linked file

That is called a "relative path". It links a file based on the current position. The ../ means a directory above, so, ../../ means two directories above.

So, ar is a link to a file that is two directories above, then descend to bin and there you will find ar.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ivan Krastev
Honored Contributor

Re: viewing the full path of the linked file

Use find command:

find /usr/x86_64-suse-linux/bin -name "*"

regards,
ivan
Jozef_Novak
Respected Contributor

Re: viewing the full path of the linked file

Hello,

what you can also do is:

# find /usr/x86_64-suse-linux/bin -type l -exec ls -l {} \;

this will give you full path to the link target.

J.
senthil_kumar_1
Super Advisor

Re: viewing the full path of the linked file

Hi

I want to see the actual path of this "../../bin/ar"

how to know the original path of this "../../"
Ivan Ferreira
Honored Contributor

Re: viewing the full path of the linked file

Try using:

which ../../bin/ar
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
macosta
Trusted Contributor

Re: viewing the full path of the linked file

Try 'readlink -m ar'

It will show you the absolute path.
Suraj K Sankari
Honored Contributor

Re: viewing the full path of the linked file

HI,
>>lrwxrwxrwx 1 root root 12 Dec 18 13:18 ar -> ../../bin/ar

from your current location do
cd ..
cd ..
cd bin
ll ar

is the location of your link file

Suraj
senthil_kumar_1
Super Advisor

Re: viewing the full path of the linked file

Hi

Still i am not able to see the full path.

# ll kini*
lrwxrwxrwx 1 root root 24 Nov 19 2007 kinit -> ../lib/heimdal/bin/kinit


# readlink -m kinit
readlink: invalid option -- m
Try `readlink --help' for more information.

# readlink kinit
../lib/heimdal/bin/kinit


macosta
Trusted Contributor
Solution

Re: viewing the full path of the linked file

It looks like I was working with a newer version of 'readlink' than you have. A SLES 9 system I have available works using 'readlink -f'

If you have further issues with readlink, please consult the manpage.
H.Becker
Honored Contributor

Re: viewing the full path of the linked file

-m is available at least with 'readlink (GNU coreutils) 6.10'

hb:~/sub/subsub$ readlink -m symlink
/home/hartmut/sub/file
hb:~/sub/subsub$

That may be what you are looking for. But, it's not the full path. -m is explained as "canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence"

hb:~/sub/subsub$ echo "`pwd`/`readlink symlink`"
/home/hartmut/sub/subsub/../detour/../file

Dennis Handly
Acclaimed Contributor

Re: viewing the full path of the linked file

>I am not able to see the full path of the linked file.

Why do you care?
Symlinks to relative paths are good, absolute paths are bad. Think of having them over an NFS mount.

The absolute path would be $PWD/../../bin/ar.