There are two types of links in Linux: Hard links and soft links (soft link), and soft links called Symbolic links (symbolic link)
To create a command:
Ln-s destfile/directory Softlink #建立软连接
ln destfile hardlink #建立硬连接
In a Linux system, the kernel allocates an inode for each newly created file, each with a unique inode number, and we can simply interpret the inode as a pointer that will always point to the specific storage location of the file. File attributes are stored in the inode, and when the file is accessed, the inode is copied to memory for fast file access. The system locates each file through an inode.
Hard links are actuallyA pointer, point to the inode of the source file, and the system does not redistribute the inode for it. Hard Connectno new inode is created, a hard connection, no matter how many, is pointing to theSame Inode node, just create a new hard link to increase the number of node connections, as long as the junction number of connections is not 0, the file exists, regardless of whether you delete the source file or the connected file.
As long as there is a existence, the file exists (in fact, it isReference CountConcept). When you modify the source file or any one of the connection files, the other files will beSynchronized Modifications。
Soft links (soft link)
Soft links The most intuitive explanation: equivalent to the Windows system shortcuts, is aStandalone File(withan independent inode, regardless of the source file inode), the content of the file is the path pointer to the source file, which can be accessed through the link to the source file. So delete the soft link file has no effect on the source file, but delete the source file, the soft link file will not find the file to point to (You can analogy Windows shortcut, you click the shortcut can access a file, but delete the shortcut, no effect on the source file).
1. Soft link and source file operation permissions are different; the hard link is exactly the same as the source file operation.
2. Soft links can cross file system (partition); Because of Inode limitations and file system offload, hard connections do not allow cross-file systems.
3. A soft connection can connect to a nonexistent file name, and a hard link is not available.
4. The soft connection can be connected to the directory, hard links are not available.
Softlink and Hardlink under Linux (RPM)