nerdexam
CompTIA

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.

Devices, Linux Filesystems, Filesystem Hierarchy Standard

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)
  • A
    4% (1)
  • C
    7% (2)
  • E
    89% (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.

AThe source file is hidden.

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.

BThe source file is read-only.

File permissions govern access to the file's content but do not prevent creation of additional hard links pointing to the file's inode.

CThe source file is a shell script.

Shell scripts are regular files and are fully eligible for hard links, just like any other non-directory file type.

DThe administrator does not own the source file.

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.

EThe source and the target are on different filesystems.Correct

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

#hard links#ln command#filesystem constraints#inodes

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice