How to create a symbolic link to a directory in Ubuntu?

Linux provides us a way with which we can create symbolic links or symlinks, that issimply pointing to another file or folder on your machine.

Now let's understand what symbolic links actually mean and how to make use of it.

Symbolic links in simple terms mean advanced shortcuts. A symbolic link that you create will appear to be the same as the original file or folder which it is pointing to, even though it’s simply a link.

For example, let’s say that you have a program that needs to store its files at /home/user/Downloads/.program. But you actually want to store those files on another partition, which is mounted at /x/partition. The way to do this via creating a symbolic link is that you can move the .program directory to /x/partition/.program, and then create a symbolic link at /home/user/Downloads/.program, and Linux will redirect it to /x/partition/.program.

Now that we understand what symbolic links actually do and how to use them, let’s learn how we can create a symbolic link between directories on Linux.

To create a symbolic link, we make use of the ln command.

The ln command in Linux is used to create soft and hard links for files and folders in Linux.


ln dir1 dir2

Example 1


ln -s /path/to/original /path/to/link

In the above command you can specify either a path to a directory or file in the command, it will work without any issue.

The -s in the command creates a symbolic link.


ln -s /home/immukul/Downloads /home/immukul/Desktop


lrwxrwxrwx 1 root root 18 May 20 11:32 /home/immukul/Desktop ->

We can also remove the sym links with the help of the following command

rm /home/immukul/Downloads