Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security, Veeam & DevOps

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form

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
  1. Home
  2. Linux
  3. 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.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • 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

  • RUST FEATURE
    How to install Rust in a Linux System Linux
  • feature photo quit vim
    How to Exit Linux Vim or Vi Editor Linux
  • SystemUtilization
    Delivering System Utilization Report on a Linux based OS Linux
  • FEATURE ZABBIX
    How to Install Zabbix Monitoring Tool on a Linux System Linux
  • Slide4
    How to install Let’s Encrypt on Apache Web Server Linux
  • SSL on WAMPServer
    Setup VirtualHost with SSL on WAMP Server Linux

More Related Articles

RUST FEATURE How to install Rust in a Linux System Linux
feature photo quit vim How to Exit Linux Vim or Vi Editor Linux
SystemUtilization Delivering System Utilization Report on a Linux based OS Linux
FEATURE ZABBIX How to Install Zabbix Monitoring Tool on a Linux System Linux
Slide4 How to install Let’s Encrypt on Apache Web Server Linux
SSL on WAMPServer Setup VirtualHost with SSL on WAMP Server 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

Veeam Vanguard

  • Diskspd
    Veeam Backup and Replication Disk I/O with diskspd Backup
  • banner
    How to install and configure FSRM in Microsoft Windows Server Windows Server
  • image 19
    Download your MySQL database from Azure to a local PC with MySQL Workbench AWS/Azure/OpenShift
  • Test your webcam and microphone before meeting
    How to Test Your Webcam And Microphone Before Meeting Windows
  • unabletouninstallonedriveonmac
    Cannot Uninstall the OneDrive App: The item “OneDrive” canot be moved to the Bin because it is open JIRA|Confluence|Apps
  • How to fix BitLocker always prompting for Recovery Key
    How to fix BitLocker always prompting for Recovery Key Windows
  • AWS Principals
    MFA on Root Account: Create a User on AWS and Register MFA AWS/Azure/OpenShift
  • Gitfixed
    GitLab-runner is not recognized as an internal or external command, operable program, or batch file Version Control System

Subscribe to Blog via Email

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

Join 1,796 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

Active Directory 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.