Learning notes for soft and hard links in Linux

Source: Internet
Author: User

1: Soft Link
Command: Ln–s/etc/inittab/test/inittab.soft
View: Ls–l/etc/initab/test/inittab.soft
Found a soft connection similar to Windows shortcut,-> represents the address of a real file
2: Hard Link
Command: Ln/etc/inittab/test/inittab.hard
View: Ls-l/etc/inittab/test/inittab.hard
The hard links are found to be exactly the same size and creation date as the real file, similar to copy, synchronized updates.
3: The difference between hard link and copy:
The found copy is different from the date the actual file was created.
4: If you want to replicate the same date, you can pass the command: CP–P/ETC/INITTAB/TEST/INITTAB2
5: Sync Update for hard links
Soft connections are similar to shortcuts, access is the source file, so it must be synchronized with the source files.
Hard links are similar to copies, but have the ability to synchronize updates, which we can verify.
First create a file link in the/test directory
(1) The soft connection file and the hard link file of the link are worn separately, Link.soft Link.hard
(2) Write data to the source file link
(3) View the contents of three files
Find hard link files synchronized updates with source files
6: Effects on hard links and soft connections after you delete the source files
A soft connection is similar to a shortcut, and it is not valid when the source file does not exist.
A hard link is a copy and still exists.
7: Why hard links can be updated synchronously?
Also creates a file link and its soft links and hard link files,
With the command ls–i, the hard link file and the source file are found to be the same as the I node number, and the kernel is based on the file's I node to identify the file, the same I node of the two files, all considered a file, all simultaneously write and modify the data.
8: Requirements of the hard link
Hard links cannot cross the file system, that is, you cannot cross partitions, similar to the hard links in C that cannot be placed in D on Windows. and soft links can be placed 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.