Diagram of the difference between soft and hard links
Summary of Hard Links
- Multiple files with the same Inode node number are hard-linked files;
- Delete a hard-link file or delete any of the source files, the file entity is not deleted;
- The file entity is deleted only if the source file and all the corresponding hard link files are deleted;
- A hard-link file is another entry for a file;
- You can prevent important files from being mistakenly deleted by setting hard-link files to files.
- Create hard-Link command ln source file hard-link file;
- Hard-link files are ordinary files that can be deleted with RM;
- For a static file (no process is being called), the file is deleted when the number of hard links is 0 o'clock. Note: If a process is being called, it cannot be deleted or even if the file name is deleted but the space is not freed.
Summary of soft Links
- Soft links are like shortcuts to Windows systems;
- Soft links inside the source file is stored in the path, pointing to the source file;
- Delete the source file, the soft link still exists, but cannot access the content of the source file;
- When the soft link fails, it is usually flashing on white-light red background;
- Create soft Link command ln-s source file soft link file;
- Soft links and source files are different files, file types are different, inode numbers are also different;
- The file type of the soft link is "L" and can be deleted with RM.
The difference principle between hard and soft links is that hard links and source files have the same inode number, and they are hard links to each other. The Inode node number of the soft connection and source file is different, and the block is different, and the path name of the source file is stored in the soft connection block. In fact, hard links and source files are the same file, and soft connections are separate files, similar to shortcuts, where the source files are stored for easy pointing. With restrictions, you cannot create hard links to a directory, you cannot create hard links to different file systems, you cannot create hard links to nonexistent files, you can create soft connections to directories, you can create soft connections across file systems, and you can create soft connections to nonexistent files.
The difference and summary of Linux hard link and soft connection