How to: Add or Remove Symbolic links in Ubuntu

How to: Add or Remove Symbolic links in Ubuntu

Unlike Windows, in Linux based systems symbolic links are use quite frequently. The advantage of using symbolic links is that they allow you to have the same file in multiple locations, but the content to remain the same across all of them regardless of where you changed the file. For example, Apache or NginX use symbolic links to enable sites from a repository of web sites available. By adding a symbolic link you can enable a site while by removing it you can disable it. This is extremely useful as it solves the issue of keeping track of updates to files that should be the same.

With that in mind here are the two main operations you need to remember when using symbolic links:

I. Use ln to create a symbolic link like this:

ln -s /usr/SourcePath/SourceFile /usr/DestinationPath/DestinationFile

II. Use unlink to remove a previously created symbolic link like this:

unlink /usr/DestinationPath/DestinationFile

 Note the use of -s in the ln command to indicate a soft link. Hard links will link to a specific version of the file and therefore it would appear as if their content is not updated when the source file’s is.

I recommend reading the man pages for ln and unlink if you want to learn more about what you can do with them.

Enhanced by Zemanta

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.