LX0-103 · Question #192
An administrator is trying to make a hard link to an ordinary file but ln returns an error. Which of the following could cause this?
The correct answer is E. The source and the target are on different filesystems. Hard links cannot span filesystem boundaries because they reference inodes, which are unique only within a single filesystem. This is the classic cause of an ln error for hard links.
Question
An administrator is trying to make a hard link to an ordinary file but ln returns an error. Which of the following could cause this?
Options
- AThe source file is hidden.
- BThe source file is read-only.
- CThe source file is a shell script.
- DThe administrator does not own the source file.
- EThe source and the target are on different filesystems.
How the community answered
(28 responses)- A4% (1)
- C7% (2)
- E89% (25)
Why each option
Hard links cannot span filesystem boundaries because they reference inodes, which are unique only within a single filesystem. This is the classic cause of an ln error for hard links.
Hidden files (those with a leading dot in their name) are ordinary files on Linux and can be hard-linked without restriction; visibility status has no bearing on linking.
File permissions govern access to the file's content but do not prevent creation of additional hard links pointing to the file's inode.
Shell scripts are regular files and are fully eligible for hard links, just like any other non-directory file type.
Ownership of the source file is not required to create a hard link; what matters is having write permission in the directory where the new link entry will be created.
Hard links work by creating a directory entry pointing to the same inode as the source file, and inode numbers are meaningful only within their own filesystem. When the source and target reside on different filesystems, the inode reference cannot be resolved across the boundary, causing ln to return an error - a symbolic link must be used in this case instead.
Concept tested: Hard link filesystem boundary restriction and inode scope
Source: https://man7.org/linux/man-pages/man1/ln.1.html
Topics
Community Discussion
No community discussion yet for this question.