Detailed explanation of soft links and hard links

Source: Internet
Author: User

Detailed explanation of soft links and hard links
GuideIn Linux, the linked files are similar to Windows shortcuts, but they are not exactly the same. There are two types of linked files: hard link and symbolic link ). Let me tell you the difference between them.

Hard Link

A hard link is a link through an index node. In Linux, multiple files are allowed to direct to the same index node, and such links are hard links. Hard links can only be linked between files in the same file system. directories cannot be created. If the source file corresponding to the hard link is deleted, the hard link file still exists and the original content is saved, which can prevent the file from being deleted due to misoperations. Since hard links have files with the same inode number but different file names, deleting a hard link file does not affect other files with the same inode number.

A hard link can be created by the command link or ln, for example:

link oldfile newfile ln oldfile newfile
Symbolic Link

The soft link (also called symbolic link) is different from the hard link. The content stored in the file user data block is the path name of another file. Soft links are common files, but the data block content is a little special. Soft links can be used to create files or directories.

Soft links are mainly used in the following two aspects: first, convenient management. For example, you can link files in a complex path to a simple path for user access; the other is to solve the problem of insufficient disk space in the file system. For example, if the space of a file system is used up, You must create a new directory under the file system and store a large number of files, you can link the directory in another file system with a large amount of remaining space to the file system, which can effectively solve the problem of insufficient space. Deleting a soft link does not affect the object to which it is directed. However, if the object to which it is directed is deleted, the soft link becomes a dead link.

Use the ln command of the-s option to create a symbolic link. The command is as follows:

ln -s old.file soft.linkln -s old.dir soft.link.dir
Expansion

Inode is called the index node number, which is the way to manage files in the Linux File System. When creating a file system, an index node table will be created, which contains a certain number of index nodes. Each time a file is created, an index node number is assigned to it, which is equivalent to the file address.

Address: http://www.linuxprobe.com/soft-hard-links-comments.html


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.