The Linux system includes two ways of linking: Hard link and symbolic link (symbolic link), in which the link is the so-called soft link (soft link), then what is the difference between the two?
Inode
In a Linux system, the kernel allocates an inode for each newly created file, each with a unique inode, where the inode is simply understood as a pointer, which always points to the exact location of the file and the file attributes are stored in the inode, such as owner. When a file is accessed, the inode is copied to memory for quick access to the file. The system locates each file through an inode.
Hard Link
Hard Lin can be understood as a pointer that points to the inode of the source file and does not produce a new inode. Hard link no matter how many, are pointing to the same inode node, but a new hard link will increase the number of node connections, as long as the node is not 0 connections, the file is always there, regardless of whether you delete the source files or connected files. As long as there is a existence, the file exists (in fact, it refers to the concept of counter). When you modify the source file or any one of the connection files, the other files will be changed synchronously. A visible example.
Symbolic Link
Symbolic Link has a separate inode, which is a standalone file, and the content of the file is a path pointer to the source file, so you can access the source file through symbolic, so deleting the symbolic link has no effect on the source file, but the source file is deleted. The symbolic link file cannot find the file to which it is pointing. This can be imagined as a shortcut in Windows.
Compare
1. The symbolic link and the source file operation permissions are different; the hard link is exactly the same as the source file operation.
2. Symbolic links can cross file systems (partitions), and because of the limitations of inode and the ability of the file system to unload, hard links do not allow cross-file systems.
3. Symbolic links can be linked to a nonexistent file name, hard links are not available.
4. Symbolic links can be connected to the directory, hard links are not available.
Two ways to link in Linux