All guides
Home Glossary Symbolic link
Term

Symbolic link

A special file type that stores a text path to another file or directory, acting as a transparent pointer for the operating system.

A symbolic link (commonly called a symlink or soft link) is a special file type that stores a text path to another file or directory, acting as a transparent pointer for the operating system. Unlike a hard link, which points directly to the same underlying data structure (inode) as the original file, a symlink simply holds the destination path as a text string. Because it is just a reference to a path, a symlink consumes negligible disk space and can point across different disk partitions, physical drives, or mounted network file systems.

How it works

When an application attempts to open, read, or write to a symbolic link, the operating system kernel intercepts the file system call and transparently redirects the request to the stored target path. To most programs, interacting with the symlink is identical to interacting with the target directly.

However, because a symlink is independent of the target file's actual data blocks, it has no awareness of changes made to the destination's location. If you move, rename, or delete the target file, the symlink remains in place as a "broken" or "dangling" link, returning a file-not-found error whenever accessed.

Example

In Linux and Unix-like environments, symlinks are standard tools for zero-downtime web deployments and software versioning. Instead of overwriting live application files, administrators deploy new code into a timestamped release directory and switch a current symlink that the web server reads from:

# Create a symlink pointing the live web root to a new release
ln -sfn /var/www/releases/v2.4 /var/www/current

# Verify the symlink target in the terminal
ls -l /var/www/current
# Output: lrwxrwxrwx 1 deploy deploy 24 Nov 14 10:00 /var/www/current -> /var/www/releases/v2.4

In the ls -l output, the leading l identifies the entry as a symbolic link, and the arrow shows the destination path. Using the -f and -n flags allows you to atomically update an existing directory symlink without creating a nested link inside the old folder.

What matters when choosing a server or hosting

  • Web server configuration: Web servers like Nginx and Apache can restrict symlink traversal to prevent unauthorized directory escapes. On shared hosting, options like Apache's FollowSymLinks may be disabled or strictly scoped to directories owned by the same user.
  • Backup and transfer behavior: Utilities like rsync, tar, and SFTP clients handle symlinks differently depending on their flags—either copying the link pointer itself or dereferencing it to duplicate the entire target directory.
  • Container and chroot boundaries: Inside Docker containers or chroot jails, an absolute symlink pointing to /var/data/file resolves relative to the container's isolated root, which often breaks links created on the host file system.

Common mistakes

  • Reversing source and destination arguments: Running ln -s link_name target_path instead of ln -s target_path link_name creates a broken link pointing to a nonexistent file or accidentally places a link inside an existing directory.
  • Using absolute paths for portable directories: Hardcoding absolute paths (such as /home/user/app/config) breaks links when directories are mounted at different paths across staging servers or containers. Relative paths are usually safer inside project repositories.
  • Creating circular references: Linking a directory to one of its own parent directories creates an infinite loop that can stall recursive file searches, backups, or automated build scripts.

FAQ

What is the difference between a symlink and a hard link?

A hard link is an additional directory entry pointing directly to the same inode and disk data as the original file; deleting the original file leaves the data intact until all hard links are removed. A symlink only stores a text path, can link directories, and can cross separate file systems, but breaks if the target is deleted.

Do symbolic links work on Windows servers?

Yes. Modern Windows versions using NTFS support symbolic links via the mklink command or PowerShell's New-Item -ItemType SymbolicLink, though creating them typically requires administrator privileges or Developer Mode enabled.

How do I safely delete a symbolic link?

Use rm link_name or unlink link_name without a trailing slash. Adding a trailing slash on some systems or recursive commands can cause tools to traverse into the target directory and delete the actual destination files instead of just the pointer.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.