Operating System - Linux
1751823 Members
5121 Online
108782 Solutions
New Discussion юеВ

Re: 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 11
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.