Linux for Developers
/Advanced
Soft vs Hard Links
Definition
Methods of creating shortcuts to files in Linux. A Soft Link (symlink) points to a file's name. A Hard Link points directly to the file's underlying inode.
Explain Like I'm New
Soft Link: A desktop shortcut. If you delete the original file, the shortcut breaks. Hard Link: Giving a file two different names. If you delete the first name, the data is perfectly safe under the second name.
Real World Example
You use `ln -s /var/www/html /home/bob/website` to create a Soft Link. Bob can now easily edit the website from his home folder. If someone deletes the `/var/www/html` folder, Bob's link turns red and says 'Broken'.
Common Use Cases
- •Organizing configurations
- •Managing multiple version installations (e.g., python -> python3.9)
Interview Questions
basic
- Which type of link can point to a directory (folder): Soft Links or Hard Links?
intermediate
- If you create a Hard Link to a 1GB file, does it consume 2GB of hard drive space total?