Linux Operations Learning notes-soft and hard links knowledge Summary

Source: Internet
Author: User
Tags parent directory

File link

Hard links, linking through index nodes

Hard link schematic diagram

Hard-Link creation:

Simply execute the command "ln source file Hard link file" to complete the hard link creation.

Hard Link Knowledge Summary:
1. Multiple files with the same inode number are hard-linked files.

2, delete the hard link file or delete any of the source files, the file entity has not been deleted.

3, only delete the source files and all the corresponding hard-linked files, the file entity will be deleted.

4, when all the hard link files and source files are deleted, and then the new data will occupy the space of this file, or the disk fsck check, the deleted data will be collected by the system.

5. Hard link file is another entrance to the file.

6. You can prevent important files from being mistakenly deleted by setting hard-link files to files.

7. Hard link files can be deleted with rm command.

8, for the static file (no process is calling the file), when the corresponding hard-link number 0 (i_link), the file is deleted. I_link View Method (the third column of the LS-L structure is)

Schematic diagram of the soft link:

a soft link or a symbolic link, equivalent to Windows the shortcut

Creating a soft Link:

Simply execute the command "ln-s source file hard-link file" to complete the creation of the soft link.

Soft Link Knowledge Summary:

1. Soft links are similar to Windows shortcuts (you can view them by Readlink).

2, soft links like a text file, which is stored in the source file path, pointing to the source file entity.

3, delete the source file, the soft link file is still stored, but unable to access the source file path to the content.

4, the failure of the time is generally the red letter white background flashing hint.

5, soft links and source files are different types of files, but also different files. The inode number is not the same.

6. Delete the soft link file can be used with rm command.

Directory Links:

for a directory, you cannot create a hard link, but you can create a soft link

Hard links to directories cannot span file systems

There is a hard link under each directory "." and a hard link to the parent directory "...".

Create a subdirectory in the parent directory, and the parent directory has a 1 increase in the number of links (subdirectories are available). To point to the parent directory). However, creating a file in the parent directory does not increase the number of links in the parent directory.

How to delete a file:

Linux is controlled by the number of link to delete the file, only if a file does not exist any link, the file will be deleted. in general, there are 2 link counters for each file: I_count and I_link.

The meaning of I_count is the number of users (or calls) of the current file, i_nlink the amount of media connections (number of hard links), which can be understood as I_count is the memory reference counter, and I_nlink is the reference counter for the disk.

Linux Operations Learning notes-soft and hard links knowledge Summary

Related Article

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.