WHY a tree is convenient: unique path ⇒ unique name ⇒ deletion is trivial (one entry, free the inode). HOW we walk it: start at /, split path on /, look up each component's inode in the current directory, repeat.
Even a "pure tree" secretly has two special entries in every directory:
. → the directory's own inode
.. → the parent's inode
These make the directory graph technically cyclic for directories, which is exactly why we ban user-created directory hard links (more below).
Imagine a big toy box (the data) with a label number painted on it. A hard link is a sticker on the wall that says "toy box #42." You can put many stickers in different rooms all saying "#42" — they all open the same box. The box keeps a little counter of how many stickers point to it; the box is only thrown away when the last sticker is removed. A symbolic link is different: it's a sticky note that just says "go to the kitchen and look for the box called teddy." If someone renames the kitchen box, your sticky note now points nowhere — a dead note. Because many stickers can point to one box, the map of names isn't a simple family tree anymore; it's a web that never loops back on itself — a DAG.
Dekho, filesystem ka asli kaam ek hi hai: naam do, data dhoondh ke do. Iske liye Unix mein name aur data ko alag rakhte hain. Data + metadata ek structure mein hota hai jise inode kehte hain, aur directory sirf ek table hai jisme (naam, inode number) ke pairs hote hain. Isi separation ki wajah se ek hi file ke kai naam ho sakte hain.
Hard link ka matlab — ek aur directory entry jo same inode ko point karti hai. Dono naam barabar hain, koi "asli" koi "copy" nahi. Inode ek link count rakhta hai = kitne naam usse point kar rahe hain. rm actually unlink call karta hai jo count ko 1 kam karta hai; data tabhi delete hota hai jab count 0 ho jaye (aur koi process file open na rakhe). Isiliye agar a.txt aur b.txt hard link hain, rm a.txt ke baad bhi b.txt se data padh sakte ho.
Symbolic link (symlink) thoda alag hai — ye ek alag inode wali special file hai jiske andar bas ek path ka text likha hota hai, jaise sticky note "wahan jao". Symlink target ki link count nahi badhata. Isliye agar target delete ho gaya to symlink dangling (toot jaata) ho jaata hai. Plus point: symlink dusre filesystem par bhi point kar sakta hai aur directory ko bhi link kar sakta hai — hard link ye dono nahi kar sakta.
Ek line yaad rakho: Hard = HEART (inode) pe point, counted; Soft = SPOT (path) pe point, not counted. Jaise hi ek file ke do alag path ban jaate hain, structure tree nahi rehta — wo DAG ban jaata hai (cycles allowed nahi, isliye directory hard links ban allowed nahi).