CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ

In a directory, `ln data h` and `ln -s data s` are run, and then `mv data data2` renames the original within the same file system. What happens on `cat h` and `cat s`?

  1. A. Both print the contents, since both links follow the inode
  2. B. Both fail, since the name data no longer exists
  3. C. cat s works but cat h fails, since hard links store the name
  4. D. cat h prints the contents, but cat s fails with no such file

Correct answer: D. cat h prints the contents, but cat s fails with no such file

A hard link is another directory entry for the same inode, so renaming the old name does not affect it. A symbolic link stores the path 'data', which no longer resolves after the rename, so it dangles.

More Operating Systems questions

Exams that ask this topic