How to create/delete symbolic links in Linux

This article will show you how to create and delete symbolic links on a Linux system.  A symbolic link is basically a file that points to another file. Note that there is only 1 copy of the actual file on the hard disk, thus saving valuable hard disk space by simply creating a link to it.

Creating a Symbolic Link

To create a symbolic link, use the syntax:
ln -s [directory or file to link] [the path of the new link]

For example, to create the link (or shortcut) /logs/mongrel.log that points to the actual file /usr/local/bin/mongrel/logs/mongrel.log, use the syntax:
ln -s /usr/local/bin/mongrel/logs/mongrel.log /logs/mongrel.log
Now, each time you want to view the mongrel.log file, you do not have to navigate to the original long path, simply go to the /logs folder

Note: You must create the /logs folder prior to creating the symbolic link

Removing/Deleting a Symbolic Link

Deleting a symbolic link is the same as removing a real file or directory. Simply use the command:
rm [filename]

Note: Deleting the symbolic link does not delete the actual file, it only removes the link.

Digg This

{ 1 Comments }
  1. Bipin Bahuguna on May 17th, 2010 at 3:09 pm

    use unlink command for remove symbolic link

    # unlink then link name

Tell us what you think about this article!