>_ IzzyLab

Hands-on task

This task is step 4 of the course “Disks, links and free space”

Make a hard link and a symbolic link

medium~5 min

There is a file /root/orig.dat. Create two links to it: a hard link /root/hard.dat and a symbolic link (symlink) /root/soft.dat. The hard link must point to the same inode as the original; the symbolic one must be a separate pointer file leading to the path /root/orig.dat.

What you'll practise:
  • ln
  • hard link
  • symlink
  • inode
  • filesystem

Topic breakdown

In Linux a file's name and the data itself are different things: data is addressed by an inode number, while a directory holds only name-links to them. A hard link is another name for the same inode (same data, shared link count; the file lives until the count drops to zero). A symbolic link is arranged differently: it's a separate small file that stores the path to the target, so it can even point to a nonexistent object. Both kinds are created by ln, and the behavior is switched by a flag.

What's checked

  1. hard link to the same inode
  2. symbolic link to the path

What it looks like