Soft links and Hard links

Source: Internet
Author: User

Soft links and Hard links
Guide The link file under Linux is a bit like a shortcut to Windows, but it's not exactly the same. There are two types of linked files: One is a hard link and the other is a symbolic link (also known as a soft link). Let me tell you the difference between them.

Hard Links

A hard link is a link that is made through an index node. In Linux, multiple files pointing to the same index node are allowed, and links like this are hard links. Hard links can only be linked between files in the same file system and cannot be created on the directory. If you delete the source file for the hard link, the hard-link file still exists, and the original content is saved, which can prevent the file from being mistakenly deleted because of the wrong operation. Because a hard link is a file with the same inode number with only a different file name, deleting a hard-linked file does not affect other files that have the same inode number.

A hard link can be created by the command link or ln, such as:

Link oldfile NewFile ln oldfile newfile
Symbolic Links

A soft link (also called a symbolic link) differs from a hard link in that the contents of a file's user data block are directed to the path name of another file. Soft link is a normal file, but the content of the data block is a bit special. Soft links can be created on files or directories.

Soft links are mainly used in the following two aspects: first, convenient management, for example, a complex path can be linked to a simple path to the user access, on the other hand, to resolve the file system disk space shortage. For example, a file system has run out of space, but now you have to create a new directory under the file system and store a large number of files, you can link another file system with more remaining space in the file system, which can be a good solution to the problem of space shortage. Deleting a soft link does not affect the file being pointed to, but if the original file being pointed to is deleted, the associated soft connection becomes a dead link.

Use the-s option of the LN command to create a symbolic link with the following command:

Ln-s old.file soft.linkln-s Old.dir soft.link.dir
Expand

The inode is called the index node number, which is how the Linux file system manages files. When the file system is established, an index node table is created with a certain number of index nodes. Whenever a file is created, he is assigned an index node number, which is the equivalent of the file's address.

Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/

Soft links and Hard links

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.