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