nerdexam
Linux_Foundation

LFCS · Question #866

After successfully creating a hard link called bar to the ordinary file foo, foo is deleted from the filesystem. Which of the following describes the resulting situation?

The correct answer is B. foo would be removed while bar would remain accessible. Deleting the original file that has a hard link only removes one directory entry; the data remains accessible through the hard link until all links to the inode are removed.

Submitted by alyssa_d· Apr 18, 2026Essential Commands

Question

After successfully creating a hard link called bar to the ordinary file foo, foo is deleted from the filesystem. Which of the following describes the resulting situation?

Options

  • Afoo and bar would both be removed.
  • Bfoo would be removed while bar would remain accessible.
  • Cfoo would be removed. bar would still exist but would be unusable.
  • DBoth foo and bar would remain accessible.
  • EThe user is prompted whether bar should be removed, too.

How the community answered

(36 responses)
  • B
    92% (33)
  • C
    6% (2)
  • D
    3% (1)

Why each option

Deleting the original file that has a hard link only removes one directory entry; the data remains accessible through the hard link until all links to the inode are removed.

Afoo and bar would both be removed.

Hard links mean multiple names point to the same data; deleting one name does not remove all other names or the data itself, unless it's the last link.

Bfoo would be removed while bar would remain accessible.Correct

A hard link creates an additional directory entry pointing to the same inode as the original file. When `foo` is deleted, its directory entry is removed, and the link count on the inode decreases, but the underlying data and the inode persist because `bar` still points to them, making `bar` fully accessible.

Cfoo would be removed. bar would still exist but would be unusable.

`bar` would remain completely usable because it is just another name referencing the identical data blocks and inode as `foo` did.

DBoth foo and bar would remain accessible.

`foo` is explicitly stated as deleted, meaning its directory entry is removed from the filesystem.

EThe user is prompted whether bar should be removed, too.

Deleting a file with existing hard links simply decrements the link count on the inode; there is no prompt to remove other links.

Concept tested: Hard link persistence after original file deletion

Source: https://man7.org/linux/man-pages/man7/symlink.7.html

Topics

#hard links#file system concepts#file deletion#inode

Community Discussion

No community discussion yet for this question.

Full LFCS Practice