Skip to content

symbolic link

A symbolic link, also called a symlink or soft link, is a special file whose content is a path to another file or directory, which the operating system follows automatically whenever a program opens the link.

The path stored in the link is called its target. It can be absolute, or relative to the directory that holds the link. The system stores it as a plain string without checking it, so the target may not exist yet. A link whose target is missing is called a dangling or broken link.

During path resolution, the operating system replaces each symlink it meets with its target and keeps walking the path. Because a link may point to another link, resolution caps the number of links it follows, and a chain that loops or runs too long fails with an ELOOP error.

Unlike a hard link, which adds a second directory entry for the same underlying file, a symlink refers to its target only by name. That indirection gives it a few distinct properties:

  • Cross-filesystem reach: A symlink can point to a file on another disk, partition, or network mount.
  • Directory targets: A symlink can point to a directory, which hard links generally can’t do.
  • Name-based binding: Renaming or deleting the target breaks the link, while a new file under the same name repairs it.

To watch name-based binding at work, delete notes.txt below, then create a new file with the same name, and compare what the hard link and the symlink read:

Interactive diagram — enable JavaScript to view.

Some system calls don’t follow the link. On POSIX systems, lstat() reports on the link itself, and readlink() returns the stored target path. Symlinks first appeared in BSD Unix in 1982, became widely available with 4.2BSD in 1983, and reached Windows with Windows Vista.

Typical uses include pointing a stable name like python3 at a versioned interpreter and switching between release directories during a deployment. Python creates and inspects symlinks through the os and pathlib modules.

Python 3 "pathlib" Module: Taming The Filesystem

Tutorial

Python's pathlib Module: Taming the File System

Handle file and folder paths the modern way with Python pathlib, a built-in module whose semantics work the same on every OS.

intermediate python stdlib

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Martin Breuss • Updated Nov. 10, 2026