The difference between soft links and hard connections for Linux

Source: Internet
Author: User

To solve the shared use of files, the Linux system introduces two kinds of links: hard links and soft links. Link for Linux system to solve the shared use of files, but also bring hidden file paths, increase permissions security and save storage and other benefits. If an inode number corresponds to more than one file name, the files are called hard links. In other words, a hard link is the same file that uses multiple aliases. Links can be created by command Ln.

Text Description:
Describe the differences between soft links and hard links under Linux
In a Linux system, there are two types of links, one hard link and another called Symbolic or soft link (soft link or symbolic).
① Create:
With the default without parameters, LN creates a hard link, and the ln command with the-s parameter creates a soft link.
The LN command cannot create a hard link to a directory, but you can create a soft link. Soft links to the directory are often used.
You can create a soft link to a nonexistent file or directory, and you cannot create a hard link.
② about Inode:
The hard link file is the same as the Inode node number of the source file, and the Inode node number of the soft link file is different from the source file.
③ Delete:
Deleting a soft link file has no effect on source files and hard-linked files.
Delete hard-linked files of files, no effect on source files and soft link files.
Deleting the source file of the linked file, without affecting the hard-link file, will cause its soft link to fail (white blinking on red background).
Deleting the source file and its hard-linked files will delete the entire file.
④ a lot of hardware device snapshot features, using a similar hard-link principle.
⑤ Soft links can cross file systems, hard links can not cross file systems.

Verify:
① Creating Links
[Email protected] ~]# mkdir test
[Email protected] ~]# CD test/
exists file
[Email protected] test]# echo source111 >> test_link
[Email protected] test]# ln-s test_link link_soft
[Email protected] test]# LN test_link link_hard
Directory exists

Non-existent file creation soft and hard links

② about Inode

Both the source file and the hard-link inode number are the same 16784637
Not the same as the software link
③ Delete
Remove soft links and hard links, no effect on source files

Delete source file, Soft link invalid

Add:
Modifying any link will modify the source file

Encouragement: I hear and I forget. I see and I remember. I do and I understand!

The difference between soft links and hard connections for Linux

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.