PrepAway - Latest Free Exam Questions & Answers

What would happen if you ran rm foo?

You have read/write permission on an ordinary file foo. You have just run ln foo bar.

What would happen if you ran rm foo?

PrepAway - Latest Free Exam Questions & Answers

A.
foo and bar would both be removed.

B.
foo would be removed while bar would remain accessible.

C.
foo would be removed. bar would still exist but would be unusable.

D.
Both foo and bar would remain accessible.

E.
You would be asked whether bar should be removed.

Explanation:
ln (without option -s) creates a hardlink of a file; creating a hardlink creates a new directory entry, but no new inode is created. Instead the new file gets the same inode as the old file, and the linkcounter is incremented. Deleting any File with a linkcount greater than 1 just removes the directory entry, the datablocks and the inode are freed only when the last link (linkcount equals 1) is deleted.


Leave a Reply