Linux hard links and soft links detailed introduction _linux

Source: Internet
Author: User

Hard links and soft links in Linux

Soft links and Hard links

Command LN

LN is the command to create the link:

To create a hard link:ln file link

To create a soft link:ln-s file Link

Hard Links

 Hard link (hard link) is the earliest way to create a link in a UNIX system.

By default, each file has a hard link, and when you create a hard link, you actually create an additional entry, and the file is actually deleted when all the hard links to the file are deleted, that is, the data block is cleaned up.

Create a hard link for a file, similar to copying a file, but the new copy and the original version are synchronized updates.

This is because all files in the Linux file system are assigned a number, called Index node number (inode index), create hard links, the Inode is the same number, so you can synchronize updates.

Two restrictions on hard links:

1. Hard links cannot point to files outside of their own file system, that is, they cannot be partitioned across hard disks (soft links can be).

2. Hard links cannot point to directories.

Soft links

Soft links (software link), also known as Symbolic links (symbolic link), can be likened to shortcuts on Windows.

Deleting a soft link does not affect the point to the file, and if you delete the file without deleting the soft link, the link exists but does not point to it, which is broken.

Summarize

Hard Links: Copy + Sync

Soft Links: Shortcuts

Thank you for reading, I hope to help you, thank you for your support for this site!

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.