How to Create a Soft Link in Linux
Ads by Google
How to create a soft link in Linux
There are some folders/directories that we use very frequently. It becomes very painful if used long path reach that directory/folder. In Linux, we can use ln -s command to create a soft link to reach the required directory/folder easily.
In above-mentioned command ln create link between files and s makes it symbolic or soft link instead of hard link.
The procedure of creating soft link
We can use a very easy name instead of a long path as link to reach certain directory/folder. Use following to create soft link for long path.
$ ln -s [original file name] [link name]
Soft link in Linux work as file shortcut feature which is used in windows operating systems. Each soft link in Linux has separate lnode value that points to the original file. Soft links can be used across different file systems. If we delete or move the file the soft link will work we have to delete the soft link or edit it otherwise it will remain as dangling pointer.
Soft link contains a path for a folder, not it’s content. A soft link also links to a directory. You can only use soft/symbolic link to link a file across filesystems.
You will see a new simple path directory in the current directory/folder after creating a soft link. You can use the following command to see the long path linked to soft link.
$ [link name] -> [original file name]
If you have colour-coded the files and directories, the soft link paths can be in an exceptional colour than everyday directories. And use the easy route directory on every occasion to attain to the long-path listing. It can save you hundreds of keystrokes and treasured time.
A soft link is also very useful when you have primary data in a directory that can change but this directory is soft lined with another directory that is fixed. So for all your work, you will be accessing data from soft link that is the same while the underlying primary data directory may change often.
How to remove a soft link in Linux
If you have decided to remove a soft link, it is very simple to do. There are two common commands in Linux to remove soft link.
- rm command
- unlike command
You can use these commands as follows:
- $ rm linkname
- $ unlike linkname
The above commands will only remove soft link, it will not delete original file or directory that you have linked.
What is a soft link in Linux?
How do I create a link to a directory in Linux?
- -s – the command for Symbolic Links.
- [target file] – name of the existing file for which you are creating the link.
- [Symbolic filename] – name of the symbolic link.
How do you create a symbolic link in Unix?
How do I find soft links in Linux?
- Open a terminal and move to that directory.
- Type the command: ls -la. This shall long list all the files in the directory even if they are hidden.
- The files that start with l are your symbolic link files.
How do I create a soft link?
Why are there no hard links to directories?
What is the difference between a hard link and a soft symbolic link in Linux?
What is the difference between soft link and hard link in Linux?
Soft Link :
Comparison Parameters | Hard link | Soft link |
---|---|---|
File system | It cannot be used across file systems. | It can be used across file systems. |
What is the option to create a hard link for a directory?
How can I tell if a directory is hard link?
What happens when you create a hard link?
What is the difference between hard link and symbolic link?
How do you update a symbolic link?
How do I remove a soft link?
What happens when you delete a soft link?
How do I remove a soft link in Windows?
Ads by Google