Creating Symbolic Links

Symbolic links are convenient shortcuts used to link existing files or directories to files or directories with more convenient locations or names. There are times when you want to have more than one path to an existing file or directory. For example, you may want to execute a program without having to type the entire path, then you can create a link to the program from the /usr/local/bin directory.

There are two kinds of links in Linux, hard and soft links.

Soft Links

a soft link is a very small file that you create in a directory. When you execute a soft link file, it will behave as you were executing the original file. But, if you delete the original file the soft link file will be nothing and useless. Think of a soft link as a call forwarding to the original file. To create a soft link, use the ln -s command. The following example will create a softlink file to originalfile.

ln -s originalfile softlink

Soft links will work across networked file systems, mounted devices, other file systems and directories.

Hard Links

a hard link is different from a soft link in the way that if you delete the original file that a hard link is pointing to, the hard link file will remain usefull. Because when you create a hard link to a file, you are creating another directory listing to point to the same inode. The only way you can delete any file on the file system is by deleting all the hard links to that file. If you make changes to the original file, all the links will reflect that change (because they are all pointing to the same inode). Use the ln command to create a hard link (without the -s option)

ln orignalfile hardlink

hard links will only work to a file on the same disk and partition as the original.


kenmax said...

lagi rajin ngepost nih pak??

kenmax said...

jadi follower gw donk... lu cari ja di blog gw bagian sidebar kanan.. dibawah messagebox..
lu tambahin juga gadget Followers, nanti gw daftar jadi followers lu.. lumyan buat naekin PR