Skip to content

How to Create a Symbolic Link (Symlink) in Linux

DodaTech 1 min read

In this tutorial, you'll learn about How to Create a Symbolic Link (Symlink) in Linux. We cover key concepts, practical examples, and best practices.

The Problem

You want a file or folder to appear in multiple places without duplicating it. Symbolic links (symlinks) are references that point to the original file.

Quick Fix

ln -s /original/file.txt /path/to/link.txt

Now /path/to/link.txt behaves exactly like /original/file.txt.

ln -s /original/folder /path/to/folder
ls -la /path/to/link

Expected output:

lrwxrwxrwx 1 user user 20 Jun 15 10:00 link.txt -> /original/file.txt

The l at the start means it's a symlink. The -> shows the target.

ln -sf /new/target/file.txt /path/to/link.txt
Type Command Works across filesystems? Points to
Symlink (soft) ln -s Yes A path
Hard link ln No The same inode (data block)

Hard links can't link to directories. Use symlinks for directories.

# Find broken symlinks
find . -xtype l

# Recreate a broken symlink
rm broken-link
ln -s /correct/path broken-link

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro