From 00122ac85c6bbb17939966edb1612e4a45c797fa Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 Aug 2025 20:24:53 +0330 Subject: [PATCH] link doc --- Linux/LPIC1/23-link.md | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Linux/LPIC1/23-link.md diff --git a/Linux/LPIC1/23-link.md b/Linux/LPIC1/23-link.md new file mode 100644 index 0000000..04656b9 --- /dev/null +++ b/Linux/LPIC1/23-link.md @@ -0,0 +1,66 @@ +# 🔗 **Linux Links: Soft Link vs Hard Link** + +## 📝 **Types of Links** + +In Linux, there are **two types** of links: + +1. ðŸŠķ **Soft Link** (Symbolic Link) +2. ðŸŠĻ **Hard Link** + +--- + +## ⚙ïļ **Commands** + +### ðŸŠķ **Soft Link (Symbolic Link)** + +Acts like a **shortcut** pointing to the original file. + +```bash +ln -s +``` + +ðŸ’Ą **Example:** + +```bash +ln -s file.txt file_link.txt +``` + +--- + +### ðŸŠĻ **Hard Link** + +Points directly to the file's **inode** (physical data on disk). + +```bash +ln +``` + +ðŸ’Ą **Example:** + +```bash +ln file.txt file_hard.txt +``` + +--- + +## 📊 **Soft Link vs Hard Link** + +| 🏷ïļ 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) +