正解:B,C,E
Explanation
A hard link is a directory entry that points to the same inode as another file. An inode is a data structure that stores the metadata and the location of the data blocks of a file. A hard link is not a separate file, but an additional name for an existing file. Therefore, the following statements are true for hard linked files:
* The hard linked files have the same permissions and owner. Since the hard linked files point to the same inode, they share the same attributes, such as the file type, the file size, the access permissions, the owner, the group, and the timestamps. Any changes made to one hard link will affect the other hard links as well. For example, if you change the permissions of one hard link, the other hard links will have the same permissions. You can use the stat command to view the attributes of a file or a hard link.
* The hard linked files share the same inode. This is the definition of a hard link. The inode number is a unique identifier for each file on a filesystem. The hard linked files have the same inode number, which means they point to the same data blocks on the disk. You can use the ls -i command to view the inode number of a file or a hard link.
* The hard linked files must be on the same filesystem. A hard link cannot cross different filesystems or partitions, because each filesystem has its own inode table. A hard link can only point to an inodethat exists on the same filesystem as the hard link. If you try to create a hard link to a file on a different filesystem, you will get an error message saying:
ln: failed to create hard link 'link' => 'file': Invalid cross-device link The other statements are not true for hard linked files, because:
* The output of stat will report hard instead of regular file. This is not true, because the stat command does not distinguish between a regular file and a hard link. The stat command will report the same file type for both the original file and the hard link, which is regular file. The only way to tell if a file is a hard link is to check the link count, which is the number of directory entries that point to the same inode. If the link count is more than one, it means there are hard links to the file. You can use the stat -c %h command to view the link count of a file or a hard link.
* The hard linked files are indicated by a -> when listed with ls -l. This is not true, because the -> symbol is used to indicate a symbolic link, not a hard link. A symbolic link, also known as a soft link, is a special type of file that contains a path to another file or directory. A symbolic link does not point to the same inode as the target file, but to the name of the target file. A symbolic link has its own inode number, file type, permissions, and timestamps, which can be different from the target file. You can use the ls -l command to view the file type, permissions, and name of a file or a symbolic link. A symbolic
* link will have the file type l and the name will be followed by a -> symbol and the path to the target file.
For example:
lrwxrwxrwx. 1 user user 9 Aug 29 15:10 link -> file
References:
* Hard links and soft links in Linux explained | Enable Sysadmin
* Hard Link in Linux: Everything Important You Need to Know
* A Brief Introduction to Hard and Soft Links in Linux - LinuxForDevices
* How to create links between files in the Linux? - Online Tutorials Library
* What is a hard link? - definition by The Linux Information Project (LINFO)