Note: This article was originally published in 2014. Some steps, commands, or software versions may have changed. Check the current Ubuntu documentation for the latest information.
In this step-by-step guide, you’ll learn add or remove symbolic links in ubuntu. Ubuntu is a popular Linux distribution based on Debian, widely used for servers and development environments.
Prerequisites
Before you begin, make sure you have:
- A system running Ubuntu (desktop or server edition)
- Terminal access with sudo privileges
- Basic familiarity with Linux command line
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 (http://kx.cloudingenium.com/linux/ubuntu/man-pages/general-commands-manual-ln/ “General Commands Manual: ln”) to create a symbolic link like this:
ln -s /usr/SourcePath/SourceFile /usr/DestinationPath/DestinationFile
II. Use (http://kx.cloudingenium.com/linux/ubuntu/man-pages/general-commands-manual-unlink/ “General Commands Manual: unlink”) to remove a previously created symbolic link like this:
unlink /usr/DestinationPath/DestinationFile
Note the use of -s in the (http://kx.cloudingenium.com/linux/ubuntu/man-pages/general-commands-manual-ln/ “General Commands Manual: 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 (http://kx.cloudingenium.com/linux/ubuntu/man-pages/general-commands-manual-ln/ “General Commands Manual: ln”) and (http://kx.cloudingenium.com/linux/ubuntu/man-pages/general-commands-manual-unlink/ “General Commands Manual: unlink”) if you want to learn more about what you can do with them.
(http://img.zemanta.com/zemified_h.png?x-id=8efc7059-02bb-4bff-96e2-61ea16b6e45a)](http://www.zemanta.com/?px “Enhanced by Zemanta”)
Summary
You’ve successfully learned add or remove symbolic links in ubuntu. If you run into any issues, double-check the prerequisites and ensure your Ubuntu environment is properly configured.