Apps Artificial Intelligence CSS DevOps Go JavaScript Laravel Linux MongoDB MySQL PHP Python Rust Svelte Vue

Create and Manage Symbolic Links on Linux

1 min read .
Create and Manage Symbolic Links on Linux

A symbolic link, or symlink, is a special filesystem entry that stores a path to another file or directory. Symlinks are useful for shortcuts, shared configuration, version switching, and keeping one canonical copy of data.

ln -s TARGET LINK_NAME

Link to a file:

ln -s /home/user/documents/report.txt /home/user/Desktop/report_link.txt

Link to a directory:

ln -s /var/www/html /home/user/webroot
ls -l /home/user/webroot
readlink /home/user/webroot

To resolve the full target path where supported:

readlink -f /home/user/webroot
rm /home/user/webroot

Removing the symlink does not remove the target. Be especially careful with trailing slashes and commands that follow directory symlinks; always verify the path before destructive operations.

You can remove and recreate it, or use ln options appropriate for your system. A simple explicit workflow is:

rm current
ln -s /opt/myapp/releases/2026-09 current

This pattern is commonly used to point a stable path at a selected release.

A symlink stores a pathname and can cross filesystems, but becomes broken if its target path disappears. A hard link refers to the same inode as another directory entry, cannot normally cross filesystems, and is generally used for regular files rather than directories.

Conclusion

Symlinks are a simple way to create alternate paths without copying data. Use ln -s to create them, readlink or ls -l to inspect them, and rm to remove only the link.

Related Posts

chevron-up