O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding a symbolic link and its target

Symbolic links are common with UNIX-like systems. We may come across various manipulations based on symbolic links. This recipe may not be having any practical purpose, but it gives practice of handling symbolic links that may be helpful in writing shell scripts for other purposes.

Getting ready

Symbolic links are just pointers to other files. They are similar in function to aliases in Mac OS X or shortcuts in Windows. When symbolic links are removed, they will not cause any harm to the original file.

How to do it...

We can create a symbolic link as follows:

$ ln -s target symbolic_link_name

For example:

$ ln –l -s /var/www/ ~/web

This creates a symbolic link (called "web") in the logged in user's home directory. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required