Linux soft link and hard connection

Source: Internet
Author: User

LinuxDifferences between soft and hard links

1: Soft link

Command:Ln-S
/Etc/inittab/test/inittab. Soft

View:Ls-l
/Etc/initab/test/inittab. Soft

The soft connection is similarWindows,->The address of the real file.

 

2: Hard link

Command:Ln/Etc/inittab 
/Test/inittab. Hard

View:Ls-L 
/Etc/inittab/Test/inittab. Hard

It is found that the size and creation date of the hard link are exactly the same as those of the real file, similarCopy, Synchronously update.

3: What is the difference between hard link and copy:

It is found that the creation date of the copy object is different from that of the real object.

4: If you want to copy data with the same date, run the following command:CP-P
/Etc/inittab/Test/inittab2

5: Synchronous update of hard links

A soft connection is similar to a shortcut. The source file is accessed, and all files must be synchronized with the source file.

The hard link is similar to a copy, but it has the synchronous update function. We can verify it again.

first, go to /test create a file in the directory link

(1) wear link soft connection file and hard link file, link. soft link. hard

(2) source file link write data

(3) View the content of the three files

Hardware-linked files and source files are synchronously updated

6: Impact of deleting source files on hard links and soft connections

A soft connection is similar to a shortcut. It does not work when the source file does not exist.

Hard links are copies and still exist.

7: Why can hard links be synchronously updated?


A file link and Its Soft link and hard link file,

run the ls-I , I the node numbers are the same, the kernel is based on the file I nodes are used to identify files, I the nodes are the same. All files are considered as one file, and all data is written and modified simultaneously.

8: Hard link requirements

Hard links cannot span file systems, that is, they cannot span partitions, similarWindowsCannotCHard link of the DiskDDisk. Soft links can be stored in any file system.

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.