Thursday, April 4, 2013

Create Symbolic Links in Ubuntu

The 2 types of links are hard links and soft links .

A hard link is essentially a file with multiple names, there are multiple copies of the file. So that if one of the hard links is deleted, the file persists to exist.

A soft link (also called symlink or symbolic link) is a file system entry that points to the file name and location. Deleting the symbolic link does not remove the original file. If, however, the file to which the soft link points is removed, the soft link stops working, it is broken.

Symbolic links can be created both from the terminal and from nautilus (file manager, GUI). 



The syntax for creating a symbolic link is,
ln -s target source
  • target - The existing file/directory you would like to link TO.
  • source - The file/folder to be created, copying the contents of the target. The LINK itself.
For more help see ln --help

ln -s /home/nargren/Pictures /home/nargren/Pictures_Backup
This would create a symbolic link directory called "Pictures_Backup" to my "Pictures" directory. All the content in either of the 2 directories would appear in the other one as well.



You can easily create a symbolic link to a folder or file by middle clicking on the folder with the mouse and dragging it to its new location, while holding the middle mouse button.

Remove Symbolic Links


To remove a symbolic link, be it a file or directory, simply remove the created link. This can be done either through nautilus (GUI) or using the rm and rm -f commands in the terminal.

Use of Symbolic Links


Symbolic links are especially useful on computers with dual-boot, running for example Windows and Linux. As symbolic links can be created across partitions and file systems, windows folders can be linked to appropriate Ubuntu folders.

I will bring my own example of using Mozilla Thunderbird as e-mail client. I would like to have my emails and profiles available, including all my downloaded emails on both operating systems. This could be done either by downloading all new e-mails when I start the software on any of the two operating systems, or via symbolic links. As I had problems downloading new emails with multiple clients, I have chosen to make a symbolic link.

I have linked my Windows
 folder to the Ubuntu directory
This allowed me to download my emails only once and have them available on both Windows and Linux while keeping my entire profile.

1 comment:

  1. Thank you Thank you Thank you . I used the second method the

    GUI method

    boy like day and night. I was ready for a nightmare to make symbolic links like I taught myself in windows and it took many days and frustration to learn. You made my life so easy with your article. Blessing on you and thank you so much. May 4 2015 new comer to Ubuntu.