codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🐧

Linux & Bash

10 / 60 topics
5File System Navigation6Creating Files and Directories7Viewing Files Content8Editing Files9File Permissions10Symbolic Links
Tutorials/Linux & Bash/Symbolic Links
🐧Linux & Bash

Symbolic Links

Updated 2026-05-15
10 min read

Symbolic Links

Introduction

In the world of Linux, files and directories are organized into a hierarchical structure. Managing this structure can sometimes be cumbersome, especially when you need to access files from multiple locations without duplicating them. This is where symbolic links come in handy. A symbolic link (often referred to as a symlink) is a special type of file that points to another file or directory. In this tutorial, we will explore how to create and use symbolic links in Linux.

Concept

Symbolic links are similar to shortcuts in Windows. They allow you to reference a file or directory from multiple locations without actually duplicating the original content. This can be particularly useful for managing configuration files, accessing frequently used directories, or organizing your file system more efficiently.

There are two types of symbolic links:

  1. Hard Links: These are direct pointers to the inode (the data structure that stores metadata about a file) on the filesystem. They behave like regular files and directories.
  2. Symbolic Links: These are special files that contain a reference to another file or directory's path. If the target is deleted, the symlink becomes broken.

In this tutorial, we will focus on creating and using symbolic links, which are more flexible than hard links.

Examples

Creating a Symbolic Link

To create a symbolic link, you can use the ln command with the -s option. The basic syntax is:

ln -s target_link_name source_file_or_directory

Example 1: Create a Symlink to a File

Suppose you have a file named example.txt in your home directory (/home/user). You want to create a symlink to this file in the /tmp directory.

<Terminal>
{`ln -s /home/user/example.txt /tmp/example_link`}

This command creates a symbolic link named example_link in the /tmp directory that points to example.txt.

Example 2: Create a Symlink to a Directory

Now, let's create a symlink to a directory. Suppose you have a directory named projects in your home directory (/home/user). You want to create a symlink to this directory in the /tmp directory.

{`ln -s /home/user/projects /tmp/project_link`}
</Terminal>

This command creates a symbolic link named project_link in the /tmp directory that points to the projects directory.

Using a Symbolic Link

Using a symlink is as simple as using the original file or directory. For example, if you created a symlink to a file, you can open it with any text editor:

<Terminal>
{`nano /tmp/example_link`}

Similarly, if you created a symlink to a directory, you can navigate into it using cd:

{`cd /tmp/project_link`}
</Terminal>

Checking Symlink Information

To check the target of a symbolic link, you can use the ls -l command. This will display the original file or directory that the symlink points to.

<Terminal>
{`ls -l /tmp/example_link`}

<OutputBlock>{`
lrwxrwxrwx 1 user user 18 May 15 10:30 /tmp/example_link -> /home/user/example.txt
`}</OutputBlock>

In the output, you can see that /tmp/example_link is a symbolic link pointing to /home/user/example.txt.

Removing a Symbolic Link

To remove a symlink, you can use the rm command. This will delete the symlink without affecting the original file or directory.

{`rm /tmp/example_link`}
</Terminal>

After running this command, the symlink /tmp/example_link will be removed, but the original file /home/user/example.txt will remain intact.

What's Next?

In the next section, we will explore how to search for files in Linux using various commands and tools. This will help you manage your file system more effectively and find the files you need quickly.

Stay tuned!


PreviousFile PermissionsNext Searching Files

Recommended Gear

File PermissionsSearching Files