Guide to adding Linux Symbolic Links

We shall see what is a symbolic link, the differences between a hard link and a symlink, how to create and remove both types, and their value in Linux.


Years ago, when I first started with Linux and wore a younger man’s clothes, one of the most challenging things for me to understand about Linux was the concept of symbolic links, and their use in the Linux environment.

Now, almost two decades later, I finally understand it. In this article, I’ll try to explain precisely what a symbolic link is, the differences between a hard link and a symbolic link, or symlink, how to create and remove both types, and their value in the Linux environment.

What is a Hard Link?

In Linux and Linux-like operating systems, virtually everything is a file.  With that in mind, in Linux, a file is just a link to an inode.  An inode is a data structure that keeps everything about a file separate from its name and the actual content.

Some Linux users like to think of a hard link as an extra name for an existing file.  So, when you create a hard link, you’re just associating two or more filenames with the same inode.


For users more familiar with Windows, a Linux hard link is much like a Windows hard link that you create with the DOS command:

C:/> mklink /h "link" "target"

That looks like a problematic concept.  Let’s see if we create a hard link in the Linux terminal; it makes things clearer.

How to create a Hard Link

We use the ln command to create link files in Linux.  The format for the ln command to create a hard link is:

# ln "source" "link"
# ln "/path/to/source" "/path to link"
# ln "target" "link"
# ln "target" "directory"

Where “source” is an existing file, and “link” is the file to create or our hard link.

So, in the following example, we are going to

Create our “source” file.

# echo 'This is the FOSS Linux Hard Link example' > FOSS

Create our “link” file.

# ln FOSS Linux

List our created “source” file (FOSS) and our “link file” (Linux).

# ls -li FOSS Linux

Creating a hard link in Linux.
Creating a hard link in Linux

If you look at our output from our ls command, we can see that the inodes match. We used the -i option specifically with our ls command so that we can see the inodes of our files, in this case, 9448255, for both.  Remember, with hard links; we’re “just associating two or more filenames with the same inode.”

Also, notice that the third column of our output shows the number 2.  That’s the total number of hard links to the file.  Here, 2.

Note that you cannot create hard links for a directory.  So, for example, you couldn’t create a hard link to refer to the directory /home/tut.  You can’t create hard links for directories and files on a different filesystem or partition, either.

What is a Symbolic Link?

Symbolic links or symlinks (sometimes called soft links) were much easier for me to digest than were hard links.  To get the gist of a symbolic link, think of a Windows shortcut.  That all a symbolic link is a pointer (or shortcut) to the actual file.  Unlike hard links, symbolic links aren’t two files referencing the same inode. Instead, the symbolic link is just a ‘shortcut’ to the actual file.

Let’s create an example of a symbolic link and explore what I mean.

How to create a Symbolic Link

Just like with a hard link, we use the ln command to create a symbolic link.  Only to create the symbolic link, we use the -s qualifier (ln -s) to specify that the link we are creating is a symbolic link.

Let’s create or symbolic link.  You’ll remember where we left off with our hard link files earlier.  We’ll build on that.

Our previously created hard links.
Our previously created hard links.

Let’s create our symbolic link file.

# ln -s FOSS Is_Great

Now, we’ll look at our files.

# ls -li FOSS Linux Is_Great

Our directory updated with our symbolic link.
Our directory updated with our symbolic link

Looking at our updated output from our modified ls command, we can see nothing’s changed with our hard links, but our symbolic link is now included.  The inode of our new file differs from our two hard links, and the second column starts with an l.  The l denotes that the file is a symbolic link.  You can see that the newly created symbolic link (or shortcut) points to the file it is a symbolic link for.  Here, FOSS (Is_Great > FOSS).


Hopefully, after reading our article, you have a better understanding of hard links and symbolic links or symlinks. If you have trouble, I cannot recommend the ln man page enough.

ln man
ln man

Should you have questions, please ask in the comments below, and we will get back in touch with you.

Travis Rose
Hi, I'm M Travis Rose, a contributor to FOSS Linux. I have over thirty years of experience in the IT arena, at least fifteen of which has been working with Linux. I enjoy converting existing Windows users to the wonderful world of Linux. I guess you could call me a Linux-evangelist. Long live Linux!


Please enter your comment!
Please enter your name here




Top 20 Git Commands with Practical Examples

If you are here reading this post, there is a high probability that you have heard or interacted with Github, and you now want to learn Git. Before we continue with showing you some of the cool Git commands, let's understand the difference between Git and GitHub.

Top 10 New Features in Linux Kernel 5.7

Linus Torvalds has announced the release of Linux Kernel 5.7 after seven weeks of development. The release announcement comes as a piece of exciting news as it brings a host of new features for the hardware manufacturers as well as the developers.

How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.


Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

3 Best Ways to Uninstall Software on Ubuntu

Uninstallation of programs can be done by graphical way using the Ubuntu Software Center, and the Synaptic Package manager. Command-line way of doing it is also possible using apt-get and aptitude commands. We shall discuss each one of them in detail.

6 Best Linux Distros for Laptops

Whether buying a Linux pre-installed laptop or selecting a Linux distro for your existing laptop, there are many things to consider. Let's take you through some of the best Linux distros that are optimized for Laptops in this 2019 edition of the article. Read on.

6 Best Linux Distros for Programmers and Developers

Linux distros have long been a favorite among programmers since the rise in popularity of the OS in the nineties. Programmers are technical by nature, and Linux distros appeal to that technical nature. Let's discuss why Linux is a great desktop OS for programmers and developers, and find out best distros suitable for them.

[Guide] apt vs apt-get commands, and which one to use?

Most Linux users, both veterans, and newbies, often get confused about what the difference between the Linux commands apt, and apt-get are and when they should use one or the other.