Find the real path of a file or folder: Use realpath command

Written by
Date: 2012-05-24 20:24:00 00:00

If you need to find the real path of a file or folder under Linux, you can use realpath.

You can use it with folders:

realpath ~/

Will output

/home/guillermo

And something like this:

realpath /usr/bin/../../tmp/../

will output

/

And you can point to a file:

Let's consider this:

ln -s /usr/bin/vim ~/vim-alias

If then you run

realpath ~/vim-alias

Will output

/usr/bin/vim