Member-only story

Linux — ln Command

Tony
5 min readNov 27, 2023

What is the ln command?

The ln command is a standard utility on Unix-like operating systems used to create links between files. It supports creating both "hard links" and "symbolic (or soft) links", providing flexibility in file management and organization.

There are two main types of links: hard links and symbolic (or soft) links. A hard link is an additional reference to an existing inode (the data structure that stores all information about a file except its name and actual data) on the disk. Symbolic link, often termed a symlink or soft link, is a separate file that acts as a reference to another file or directory’s path. It’s akin to a shortcut or a pointer.

Hard link example:

$ ls -l
-rw-r--r-- 2 user user 29 Oct 18 12:00 hardlink_to_original
-rw-r--r-- 2 user user 29 Oct 18 12:00 original_file.txt

Notice that both the original_file.txt and hardlink_to_original have the same inode count (2), indicating that both entries point to the same inode. The file size and permissions will also be identical.

Soft link example:

$ ls -l
-rw-r--r-- 2 user user 29 Oct 18 12:00 original_file.txt
lrwxrwxrwx 1 user user 16 Oct 18 12:02 softlink_to_original -> original_file.txt

--

--

Tony
Tony

Responses (1)