Files

1.6 KiB

🔗 Linux Links: Soft Link vs Hard Link

In Linux, there are two types of links:

  1. 🪶 Soft Link (Symbolic Link)
  2. 🪨 Hard Link

⚙️ Commands

Acts like a shortcut pointing to the original file.

ln -s <base-file> <link-file>

💡 Example:

ln -s file.txt file_link.txt

Points directly to the file's inode (physical data on disk).

ln <base-file> <link-file>

💡 Example:

ln file.txt file_hard.txt

🏷️ Feature 🪶 Soft Link (Symbolic) 🪨 Hard Link
🔢 Inode Number Different from the original file Same as original file
🗂 Cross Filesystem Yes No
If Original Deleted Link breaks (becomes invalid) File still exists
📦 Storage Stores path to original file Stores actual data reference
🔄 Update Reflects changes in original file Reflects changes (same inode)

🧠 Quick Notes

  • Soft Link → Think shortcut 📎

  • Hard Link → Think clone reference 📀

  • If you delete the base file:

    • 🪶 Soft Link → Broken link
    • 🪨 Hard Link → Still works (data intact)