A symbolic link creates a file in your directory and is a shortcut to a file or folder. It’s similar to the Windows shortcut file.
ln is a command-line utility for creating links between files. By default, the ln command creates hard links. To create a symbolic link, use the -s (–symbolic) option.
Create Symbolic for Folder
Table of Contents
I have a directory- let’s say apache-tomcat-9.0.27 under /home/narayanatutorial/installation/ However, I want a shortcut/symbolic for apache-tomcat-9.0.27 in /home/narayanatutorial/
Syntax: ln -s <source-folder-path> <short-cut-folder-path> Example: ln -s /home/narayanatutorial/installation/apache-tomcat-9.0.27 /home/narayanatutorial/tomcat
Here -s stands for symbolic.
Create Symbolic for File
I have a file – let’s say apache-tomcat-9.0.27/conf/server.xml under /home/narayanatutorial/installation/ However, I want a create shortcut/symbolic link for server.xml in /home/narayanatutorial/
Syntax: ln -s <source-file-path> <short-cut-file-path> Example: ln -s /home/narayanatutorial/installation/apache-tomcat-9.0.27/conf/server.xml /home/narayanatutorial/tomcat-server.xml
Remove Symbolic via rm
Remove symbolic command is a simple like as remove the file
Syntax: rm <symbolic-file-path> Example: rm /home/narayanatutorial/tomcat
Remove Symbolic via unlink
We can use the unlink command to remove the symbolic as follows
Syntax: unlink <symbolic-file-path> Example: unlink /home/narayanatutorial/tomcat
Overwriting Symbolic or Forcefully change the sysmbolic
If you try to create a symbolic link that already exists , the ln command will print an error message.
To overwrite the destination path of the symlink, use the -f (–force) option.
Syntax: ln -sf <source-file-path> <short-cut-file-path> Example: ln -sf /home/narayanatutorial/installation/apache-tomcat-9.0.27/conf/server.xml /home/narayanatutorial/tomcat-server.xml
Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in the IT industry for more than 12 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting, Website Development, and IAM(ForgeRock) Specialist
I am a self-learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.