Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.
ls -l java
lrwxrwxrwx 1 root root 22 2019-02-17 11:37 java -> /etc/anotherLink/java

when I do ls -l it shows path to file, but that file can also be a link. is there any way to show path to real file?

share|improve this question

2 Answers 2

I think what you want is readlink:

readlink -f java

To find this, I asked which manual page might by appropriate for symbolic links.

apropos "symbolic link"

It returned a reference to readlink, so I used the manual:

man readlink

I read the manual page:

-f, --canonicalize canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist

Is this what you are looking for?

share|improve this answer

Try using file command.

It shows details about a given file (type, contents format)

Example:

$ cp -s temp.sh temp2.sh
$ file temp2.sh 
temp2.sh: symbolic link to `temp.sh'
share|improve this answer
    
I think the question is about one more level of links, e.g. one (link) -> two (link) -> three (regular file) and a command to show one points to three. file one will show one: symbolic link to 'two' whereas readlink -f one will show /abs/path/to/three. –  gertvdijk May 30 '13 at 9:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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