Operating Systems & Administration

[Day 7] 2. Hard Link and Symbolic Link

D
DITISS Admin
••4 min read

Hard Link

A hard link is essentially another name for the same file. It doesn’t create a new file; instead, it creates an additional directory entry that points to the same inode (a structure that stores metadata about the file).

Key Points

  • Same inode number: Both the original file and the hard link share the same inode and thus the same File Control Block (FCB) and data block.
  • Link count increases: When a hard link is created, the link count of the inode increases, indicating how many directory entries point to the same file.
  • File is not deleted: If the original file is deleted, the data remains available through the hard link because the inode and data block are still in use until the link count becomes zero.
  • No new data block: Hard links do not consume additional disk space beyond the new directory entry.

!2. Hard Link.png

Example

ln f1.txt f2.txt

  • Both
    f1.txt
    and
    f2.txt
    will now point to the same data.

When to use Hard Links?

  • When you need multiple names for the same file in the same file system and want changes to one file to reflect in the other.

Symbolic Link

A symbolic link (or symlink) is a special type of file that points to another file or directory by its path. It is like a shortcut.

Key Points

  • Different inode numbers: A symbolic link has its own inode and FCB, but it only stores the path to the target file.
  • No increase in link count: The original file's link count doesn’t change when a symbolic link is created.
  • New data block: A new data block and FCB are created for the symbolic link, which holds the path to the original file.
  • Broken link if the original file is deleted: If the original file is deleted, the symbolic link points to nothing, and attempting to use it will result in an error unless a new file is created with the same name.

!2. Symbolic Link.png

Example

ln -s f1.txt f2.txt

  • f2.txt
    will act as a shortcut to
    f1.txt
    . If
    f1.txt
    is moved or deleted,
    f2.txt
    will be broken.

When to use Symbolic Links

  • When you need to link to files across different file systems or partitions.
  • To create shortcuts (like on the desktop).

Differences Between Hard Link and Symbolic Link

| Feature | Hard Link | Symbolic Link | | ------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------------- | | Inode | Shares the same inode as the original file | Has its own inode; contains the path to the file | | Link Count | Increases the link count of the original file | Does not affect the link count of the original file | | Storage | Points directly to the data block | Stores the path of the target file | | Deletion Impact | File data remains accessible via the link even if the original is deleted | If the original file is deleted, the link becomes broken | | Cross-Partition | Cannot be used across different file systems or partitions | Can link to files across different partitions or file systems | | Use Case | To create multiple names for the same file | To create shortcuts or link to files across directories or file systems |


Read Next

8/26/2026

[Day 7] 3. Back to Shell Scripting

### **Positional Parameters** Positional parameters are arguments passed to a script from the command line when you execute it. They allow you to p...

8/26/2026

[Day 1] 1. Operating System

!1. OS.png ### **Operating System (OS)** An Operating System is a crucial software that enables hardware to function by acting as an interface b...