ln 显示文件的类型
Syntax format: ln "option" "Source" "Target" file [option] [meta file or directory] [destination file or directory]
Attention:
- The file command and subsequent options and files must have at least one space between each element
Option Description:
parameter Options |
Explanatory notes |
No parameters |
Create a hard link |
-S |
Creating a soft connection |
Case one:
Hard Links
Hard Link Summary:
- Multiple files with the same Inode node number are hard-linked files to each other
- Delete Hard link my file or delete the original file any one, the file entity is not deleted
- The file entity is deleted only if the original file and all the corresponding hard link files of the original file are deleted.
- However, after all the hard link files and the source files are deleted, the file space will be occupied when the new data is stored, or when the disk fsck is checked, the deleted data will be collected by the system.
- A hard-link file is another entrance to the file
- You can prevent important files from accidentally deleting files by setting hard-link files to them.
- Execute the command "ln source file Hard link file" to complete the hard link creation
- Hard-link files can be deleted with the RM command
- For a static file (no process is picking the file), when the corresponding hard connection number is 0 o'clock, the file will be deleted, I_link view method is Ls-lih, view the result of the third column, that is, the number of hard links.
Case TWO:
Soft connection
Soft Connection Summary:
- Soft joins are similar to shortcuts in Windows
- A soft connection is similar to a text file in which the source file is stored, pointing to the source file entity
- The soft-connect file still exists, even though the source file is deleted, but the source file path content that points to is inaccessible
- When it fails, it's usually a red font flashing.
- Implement the command "ln-s source file Soft Connection file" to complete the creation of a soft connection
- Soft joins and source files are different types of files and are different files, and inode numbers are not the same.
- To delete a soft connection file, you can use the RM command
Linux Common Commands--ln