ISO27001:2013
Certified Supplier

FIND OUT MORE

We're an ISO27001:2013 Certified Supplier

blog-post-featured-image

One of the very powerful features of Linux file systems is symbolic links, more commonly known as soft links or simply symlinks. Symlinks make it much easier to get to a commonly used file or directory. Let’s assume we have a deep directory tree and want to make it easy to access myfile within it:

Now we can refer to that file as either shortcut/myfile or deep/directory/tree/myfile from the current directory.

Symlinks can point to other symlinks. For example, on the Debian system I’m typing this on, /usr/bin/vim is a symlink:

But the place it points to is also a symlink:

That’s not an uncommon configuration to handle the update-alternatives(1) mechanism.

Finding the True Path

There’s a really simple what of finding out where the real file is: realpath. Here it is in action:

When we traverse symlinked directories to get to our working directory, it can even be confusing as to where we are, because pwd will show the path with symlinks:

However, realpath can show where we really are:

Was This Linux Tip Useful?

Let us know in the comments below.

1 thought on “Linux Tips: Finding the Real Path”

Leave a Reply

Your e-mail address will not be published. Required fields are marked *