Pages

Saturday, June 12, 2010

Ubuntu - Link the folders with "ln"

 Hello folks,
            The purpose of writing this blog is only because i want to link two folders and when i tried to google it no good reults are there that can satisfactory show you how the two folders are linked. So here I will describe the most simple way how you can link two folders.

           The command you are looking for is "ln". This command creates the symbolic links in the Linux. The word "Symbolic" means that no matter you enter in any of the two linked folder you will end up in the same physical location. So now when you make changes to any of the folder it will reflect to the other folder also. So it means that it is shown to you as two different folders but actually they are one folder with two different names. This two folders can be in any directories, any path, it doesn't matter.

        Example:
          Say i have following structure of directories
            /root/
            /root/source/
            /root/dummy/

          And i want to link the "source" directory with say "link" directory

          you don't need to create the directory named "link" it will be created automatically.

          Run the following command
          ln -s /root/source /root/link
Note :  You can remove the "link" folder when ever you like to remove the link because it is just a link not actual folder. while if you remove the "source" folder then the "link" folder will not have any physical link to go to. so you will be stuck with the dead link.

        for more regarding command "ln" please check the manual page of ln - click here. there is wiki page for "ln" click here.

No comments: