Linux Foundation Certified System Administrator Exam: Resulting Situation of Deleting a File with a Hard Link

Understanding the Resulting Situation of Deleting a File with a Hard Link

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?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

B

When creating a hard link, it creates a new name (bar) for an existing file (foo) in the same file system, essentially creating another pointer to the same inode (a data structure that stores information about a file, such as ownership, permissions, and location). Therefore, removing foo from the filesystem does not actually remove the file data, as there is still another pointer (bar) to the inode that contains the data.

Thus, the correct answer is D: Both foo and bar would remain accessible.

Removing foo from the filesystem does not affect the data pointed to by bar, and so bar would still exist and be accessible. Note that removing bar would also not affect the data, as there is still the original inode with its data intact.

Option A is incorrect because removing foo does not remove the data, as explained above. Option B is incorrect because bar is still a valid pointer to the data. Option C is incorrect because bar is still usable. Option E is incorrect because the user is not prompted for anything, as the data is still accessible through bar.