How to Create Symbolic Links Using ln -s

How to Create Symbolic Links Using ln -s

Hey there! 👋 If you're new to Linux, you've probably seen the term "symbolic link" or "symlink" floating around. But what exactly is it? And why would you want to use it?

In simple terms, a symbolic link is like a shortcut or alias to another file or directory. It doesn't hold the actual content, but it *points* to something else—just like how a desktop shortcut opens a file from another location.

🧠 Why Use Symbolic Links?

  • To avoid duplicating large files or folders
  • To organize files across multiple locations
  • To make configurations cleaner and more maintainable

🛠️ Basic Syntax


ln -s [target] [link_name]

Let’s break this down:

  • [target] — This is the original file or directory you want to link to.
  • [link_name] — This is the name of the symbolic link you’re creating.

📁 Example 1: Linking a File

Let’s say we have a file called report.txt in our Documents folder, and we want to create a symbolic link to it on the Desktop.


cd ~/Desktop
ln -s ~/Documents/report.txt report-link.txt

Now we can check the link:


ls -l report-link.txt

lrwxr-xr-x  1 user  group  25 Jul  2 10:00 report-link.txt -> /home/user/Documents/report.txt

The arrow (->) confirms that report-link.txt is a symlink pointing to report.txt.

📂 Example 2: Linking a Directory

You can do the same for a directory. For example, link a project folder to your home directory:


ln -s ~/projects/myapp ~/myapp-link

ls -l ~/myapp-link

lrwxr-xr-x  1 user  group  20 Jul  2 10:15 myapp-link -> /home/user/projects/myapp

🧹 To Remove a Symbolic Link

Just delete it like a regular file:


rm report-link.txt

Don’t worry — this won’t touch the original file.

⚠️ Common Pitfall: Relative Paths

If you use a relative path instead of an absolute one, the link will break if you move it to a different location. Always prefer absolute paths when in doubt.

✅ Recap

  • Use ln -s to create symbolic (soft) links
  • They act like shortcuts, saving space and effort
  • Work with both files and directories
  • Use absolute paths for stability

That’s it! 🎉 Now you know how to use symbolic links to simplify your file and directory management in Linux. Go ahead and try it out!