Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Contact
  • Reviews
  • Toggle search form
Home » Linux » All You Need to Know About Symbolic Links in Linux
  • Convert MP4 to MP3
    2 Free Ways to Convert MP4 to MP3 Reviews
  • 2019computers windows 10 window on blue background 131108 29
    This installation package could not be opened: Verify that the package exists and that you can access it Windows
  • Add User to Sudoers
    Add a User to the Sudoers List in Linux Linux
  • powershell
    How to install the Microsoft PSWindowsUpdate module silently Scripts
  • nested virtualization
    Enable the Virtual Machine Platform Windows Feature and ensure Virtualization is enabled in the BIOS Virtualization
  • 0227 15
    How to set Execution Policy via Windows PowerShell Windows Server
  • windows 10 creators
    Various methods on how to launch Windows Task Manager Windows
  • office configuration analyzer tool offcat
    Office Configuration Analyser Tool (OFFCAT): Now Microsoft Support and Recovery Wizard Microsoft Exchange/Office/365

All You Need to Know About Symbolic Links in Linux

Posted on 24/01/202220/06/2025 Imoh Etuk By Imoh Etuk No Comments on All You Need to Know About Symbolic Links in Linux
PersonalHow-to-Create-Symbolic-Links-in-Linux

In this post, you will learn about “All You Need to Know About Symbolic Links in Linux to a file and directory. Also, on how to overwrite a symbolic link, and how to delete/remove a symbolic link”. In Linux, creating symbolic links is one of the common tasks of a system administrator. Operate on symbolic links as real files, except when deleted. Please, see Fix long path names to files on SQL Server installation media error, and how to Install SQL Server Management Studio 21 on Windows Server.

System admins and users have this capability. This allows you to have multiple access points to a file. Without having excess copies (that remain up to date since they always access the same file).

Also, see how to install and update PowerShell version 7 on Windows and Linux, how to install Windows Server 2025 via iDRAC Virtual Media or PXE, and all you need to know about Microsoft Defender Antivirus.

What are Linux Symbolic Links?

A symbolic link also known as a symlink. It is a type of file in Linux that points to another file or a folder on your PC. Symbolic links are similar to shortcuts in Windows Operating System.

In other words, a symbolic link is a special kind of link that helps you quickly locate another file or folder on your computer or a connected file system.

Please see how to manage and use Amazon S3 access points using the AWS Management Console, and Windows Computer to Your Microsoft Account: Easy Connection Steps.

This is similar to a Windows shortcut. Symbolic links can take two forms: That’s Soft Links and Hard Links.

  1. Soft links are similar to shortcuts and can point to another file or directory in any file system. It is an indirect pointer to a file or directory. Unlike a hard link, a symbolic link can point to a file or a directory on a different filesystem or partition.
  2. Hard links are file shortcuts, but cannot cross file system boundaries or be created for folders.

    You can think of a hard link as an additional name for an existing file. Hard links are associated with two or more file names with the same inode.

    You can create one or more hard links for a single file. You cannot create hard links for directories and files on a different filesystem or partition.

You may also be interested in learning about the following: how to Install Terraform on Linux, how to Save Read-Only Files in VIM Editor in Linux/Unix-like OS, how to automate a process in Linux: The art of shell scripting, and how to Locate, Find, and Grep: How to search for files and patterns in Linux/Unix-like OS

Understanding the ln command

The ln is a command-line utility for creating links between files in Linux/Unix-like Operating System. The ln command syntax for creating symbolic links is as follows: By default, the ln command creates hard links. To create a symbolic link, use the -s (--symbolic) flag option.

The ln the command syntax for creating symbolic links is as follows:

ln -s {options} file link
  • If both the file and link are given, ln will create a link from the file specified as the first argument {file} to the file specified as the second argument {link}.
  • If only one file is given as an argument or the second argument is a dot {.}, ln will create a link to that file in the current working directory . The name of the symlink will be the same as the name of the file it is pointing to.

By default, on success, ln doesn’t produce any output and returns zero. Also, see Restore Point Creation in Windows 10 and Windows 11, and why Data recovery is almost impossible from an overwritten Hard Drive.

How to Create Symbolic Links to a File 

To create a symbolic link to a given file, open your terminal and type:

ln -s source_file symbolic_link

Replace source_file_name with the name of the existing file for which you want to create the symbolic link and symbolic_link_name with the name of the symbolic link.

The symbolic_link _name  parameter is optional. If you do not specify the symbolic link, theln command will create a new link in your current directory:

In the following example, we are creating a symbolic link named searchtext_link.txt to a file named mysearchtext_link.txt in our terminal:

ln -s searchtext_link.txt mysearchtext_link.txt
Linux Operating System
Linux OS
Creating Symlink in Linux

Now, you can see from the screenshot above that we have the Symbolic Link created and highlighted, and pointing to the source file searchtext_link.txt. You can verify this by running the

To verify that the symbolic link was successfully created, let’s use the ls command to preview it:

Linux Distribution

Understanding the Output of Symbolic Link

Symlink-output
The Output of a Symbolic Link

From the screenshot, the l character is a file-type flag that represents a symbolic link. The -> the symbol shows the file the symbolic link is pointing to.

The rest of the characters after the l that’s rwxrwxrwx represent the various read, write and execute permissions in Linux usually represented as 777 or 111 in binary. To learn more about file write and read permission. Refer to the article on how to Save Read-Only Files in VIM Editor in Linux/Unix-like OS

Create Linux Symbolic Links to a Directory

The command for creating a symbolic link to a directory is the same as when creating a symbolic link to a file. Specify the directory name as the first parameter and the symbolic link as the second parameter.

For example, if you want to create a symbolic link from the /home/pictures/my_pictures directory to the ~/my_picturesthe directory you would run:

ln -s /home/pictures/my_pictures ~/my_pictures
Symlink-to-Directory

How to overwrite Symbolic Links

Sometimes when you create a Symbolic with a name similar to the one you have already created, you will be prompted link already exists, the ln The command will print an error message.

Let’s say we want to recreate a symlink to the same file name we have already created above that’s searchtext_link.txt to mysearchtext_link.txt

To overwrite the destination path of the symbolic link, use the -f (--force) flag option as shown below:

ln -sf searchtext_link.txt mysearchtext_link.txt
Symlink-failed-to-create-1
Overriding-Symlink
Overwrite Symbolic Links

How to Remove Linux Symbolic Links

To delete/remove symbolic links use either the unlink or rm command. The command to unlink a symlink is very easy to remember. To do so use unlink symbolic link_to_remove. An example of how the command should be written in the terminal is shown below:

unlink mysearchtext_link.txt

Removing a symbolic link using the rm (remove) The command is the same as when removing a file. You can achieve this by simply running:

rm symlink_to_remove
Please note, no matter which command you us when removing a symbolic link do not append the / trailing slash at the end of its name. If you delete or move the source file to a different location, the symbolic file will be left dangling (broken) and should be removed.

In summary, to create a symbolic link in Linux use the ln command with the -s flag option. To learn more about the ln command, make use of the man command which is the command used to display the user manual of any command run on the terminal.

The man command will help provide a detailed view of the ln command. To do so, type man ln in your terminal and read through the information.

I hope you found this blog post helpful on All You Need to Know About Symbolic Links in Linux. Please let me know in the comment section if you have any questions.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:Terminal, Ubuntu

Post navigation

Previous Post: Cyclic Redundancy: Resolve Data Error on Inaccessible Hard Drive
Next Post: Create and Delete AD DS Partition with NTDSUTIL.EXE

Related Posts

  • PlayF
    How to Install PlayonLinux on a Linux System Linux
  • sshfs
    Mounting remote directory using sshfs Linux
  • screenshot 2020 04 23 at 00.30.09
    How to mount a USB Drive in Linux Linux
  • Webp.net resizeimage 1
    Automate Infrastructure Deployments in the Cloud with Ansible and Azure Pipelines AWS/Azure/OpenShift
  • FEATURE IMAGE
    SSH into a VM created using Azure CLI or GUI Linux
  • Screenshot 2020 05 14 at 18.00.59
    Linux Error 13: Permission denied, are you root Linux

More Related Articles

PlayF How to Install PlayonLinux on a Linux System Linux
sshfs Mounting remote directory using sshfs Linux
screenshot 2020 04 23 at 00.30.09 How to mount a USB Drive in Linux Linux
Webp.net resizeimage 1 Automate Infrastructure Deployments in the Cloud with Ansible and Azure Pipelines AWS/Azure/OpenShift
FEATURE IMAGE SSH into a VM created using Azure CLI or GUI Linux
Screenshot 2020 05 14 at 18.00.59 Linux Error 13: Permission denied, are you root Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a
 
  • Convert MP4 to MP3
    2 Free Ways to Convert MP4 to MP3 Reviews
  • 2019computers windows 10 window on blue background 131108 29
    This installation package could not be opened: Verify that the package exists and that you can access it Windows
  • Add User to Sudoers
    Add a User to the Sudoers List in Linux Linux
  • powershell
    How to install the Microsoft PSWindowsUpdate module silently Scripts
  • nested virtualization
    Enable the Virtual Machine Platform Windows Feature and ensure Virtualization is enabled in the BIOS Virtualization
  • 0227 15
    How to set Execution Policy via Windows PowerShell Windows Server
  • windows 10 creators
    Various methods on how to launch Windows Task Manager Windows
  • office configuration analyzer tool offcat
    Office Configuration Analyser Tool (OFFCAT): Now Microsoft Support and Recovery Wizard Microsoft Exchange/Office/365

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,841 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.