Create Symlink for Directory
A link can also point to a folder’s location (path). Use this command to create a link to a folder in Linux.
Command :
ln -s [target folder] [name for the link]
For example, to create a link called “test-link” in your home folder that points to a folder on a CD drive.
Command :
ln -s /media/marko/VBox_GAs_6.1.38/cert ~/test-link
Output :
The ls command will now show the new link file “test-link” in your home folder. If you type ls -l, you’ll see the letter l at the start, which means it’s a link. The output also shows the path of the target folder that the link points to. When you open the “test-link” folder, you’ll see the same contents as the “cert” folder on the CD drive.
How to Use ln Command to Create Symbolic Links in Linux
A symbolic link (symlink) is like a shortcut that points to a file or folder on Linux and other similar operating systems. Symlinks can be useful for organizing files and folders, or for making it easier to access files from different locations.
In this guide, you’ll learn how to create symbolic links in Linux using the ‘ln’ command.
Use ln Command to Create Symbolic Links in Linux
- What Is a Symlink (Symbolic Link)?
- How to Create Symbolic Link in Linux (ln Command)
- Create Symlink for Directory
- Overwrite Symbolic Links
- Find Broken Symbolic Links
- Remove Symbolic Links