How to create/remove symlinks (symbolic link) in Linux

rpm dependencies, linux, ubuntu

This article will show you how to create and delete symbolic links on a Linux system such as Ubuntu, Red Hat, and other Linux distributions.  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 in Linux

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 in Linux

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.

See also  How to Restart SSH in Solaris 10/11

3 thoughts on “How to create/remove symlinks (symbolic link) in Linux”

Leave a Comment