The link files in a Linux system are broken down into hard links and soft links (soft links are also called Symbolic links).
1. Hard link is to create an inode pointing to the block, there is the ability to prevent accidental deletion. Because deleting a file actually deletes the inode information and cuts the connection between the Inode and the block. When a hard link is made to a file, deleting the file will only reduce the number of links to the file, and the file will be completely deleted when the number of links is 0 o'clock.
Soft links like Windows system shortcut, is a complete file, has its own inode and block,block content is the file name of the original file. When the original file is deleted, the soft link becomes invalid and there is no function to prevent accidental deletion.
2. The file size is different. Because the hard link is the block that points to the original file, the file size of the hard link is consistent with the original file size. And the soft link is a new file, block is the original file name, so the size of the soft link file is generally 4K, that is, the size of a block. The source file must exist when the hard link is created, and the source file may not exist when the soft link is created
3. You cannot create a hard link to a directory, but you can create a soft link to a directory that cannot be created across extents and a soft connection can.
4. Hard link file display link l, soft link file does not show link l; hard-Link file owner, group, other, link number, size, creation time is consistent with source file, change one of the files will change, and soft links are not maintained with the source file, and will not be pinned
To create a hard-link command:
ln file NewFile #file为原文件名, NewFile is the new file name.
To create a soft link command:
Ln–s file NewFile #file为原文件名, NewFile is the new filename.
The difference between a soft link and a hard link under Linux