LX0-103 · Question #67
Which of the following pieces of information of an existing file is changed when a hard link pointing to that file is created?
The correct answer is C. Link count. Creating a hard link increments the inode's link count because both the original name and the new hard link are directory entries pointing to the same inode.
Question
Which of the following pieces of information of an existing file is changed when a hard link pointing to that file is created?
Options
- AFile size
- BModify timestamp
- CLink count
- DInode number
- EPermissions
How the community answered
(21 responses)- B5% (1)
- C95% (20)
Why each option
Creating a hard link increments the inode's link count because both the original name and the new hard link are directory entries pointing to the same inode.
File size is stored in the inode and reflects actual data blocks; creating a directory entry that points to the inode does not add or remove data.
The modify timestamp (mtime) is updated only when file content changes; adding a hard link modifies no file data, so mtime is unaffected.
Every inode maintains an `st_nlink` field that counts how many directory entries reference it. When a hard link is created with `ln`, the kernel adds a new directory entry pointing to the existing inode and atomically increments that link count by one. The file's data, size, timestamps, permissions, and inode number remain completely unchanged.
Hard links share the exact same inode number as the original file - that shared inode is precisely what defines a hard link.
Permissions are stored in the inode and are therefore identical across all hard links to the same file; creating a new link does not alter them.
Concept tested: Hard link creation effect on inode link count
Source: https://man7.org/linux/man-pages/man1/ln.1.html
Topics
Community Discussion
No community discussion yet for this question.