How To Find What Symlink Points To

To some this may seem like a trivial task, but I see great interest from Unix/Linux beginners arriving to this blog: how exactly does one confirm what a symlink points to?

First of all, if you haven’t already done so – read my Unix Symlink Example post to learn what a symlink is and to refresh your mind about creating symlinks.

If you’re still reading, perhaps a bit more explanations are needed.

Since symlink is nothing but a special Unix file, you can use all the standard Unix commands to work with it – list it or remove it for example.

For listing files, the most obvious choice is a Unix ls command, and the way you use it to list symlink is the same way you’d list any other file:

ubuntu$ ls ubuntu-release

Now we come to exactly the reason why some people don’t find working with symlinks obvious: when we list the symlink, we expect to see the file it points to. More precisely, we expect to see the name of this file.

To show what a symlink points to, you need to use a long format of the ls command:

ubuntu$ ls -l ubuntu-release
lrwxrwxrwx 1 greys greys 10 2008-03-23 16:53 ubuntu-release -> /etc/issue

As you can see, the ubuntu-release symlink points to the /etc/issue file.

See also

Contact Me

Follow me on Facebook, Twitter or Telegram:
I learn with Educative: Educative
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!
Recent Articles
24 Mar 2024

Homelab: Mac Pro 2013 32GB

30 Sep 2023

macOS Sonoma 14.0

26 Sep 2023

Video: What Browser Do You Use?

Recent Tweets