How to Make and Remove Symlink in Linux RHEL 7

How to Make and Remove Symlink in Linux RHEL 7
How to Make and Remove Symlink in Linux RHEL 7

How to Make and Remove Symlink in Linux RHEL 7 - Hello everyone, welcome to the kitsake.com blog. I hope you are all doing well and always blessed with ease in everything, be it in life or work. Amen.

In this discussion, I will explain How to Make and Remove Symlink in Linux RHEL 7. The reason I am making this post is that I found something new when setting up a web server, where the source code inside the RHEL 7 server uses uncommon commands or is directed to custom paths by the programmer.

Therefore, in such cases where the programmer is unwilling to make changes to the coding, I, as the system engineer, take action. This is done by creating a symlink, which is commonly known in Windows operating system as a shortcut. How do you do it? Follow the steps and examples I provide below.

A brief explanation of command ln

ln - make links between files. In the 1st form, create a link to TARGET with the name LINK_NAME.  In the 2nd form, create a link to TARGET in the current directory.  In the 3rd and 4th forms, create links to each TARGET in DIRECTORY. Create hard links by default, symbolic links with --symbolic.  

By default, each destination (name of new link) should not already exist.  When creating hard links,  each  TARGET  must exist.   Symbolic links can hold arbitrary text; if later resolved, a relative link is interpreted about its parent directory.

Make symbolic link

Above, the 'ln' command has been explained. With the explanation given, you should already understand. To create a symbolic link, you can follow my method below. This method is very simple, and you can definitely do it too.

# cd /home/kitsake/
# ln -s [source] [destination]
# ln -s /root/dota2/ ggwp
Make symbolic link
Make symbolic link

Above, I demonstrated how to create a symlink in Linux RHEL 7 from the path /root/dota2 to the folder ggwp located within the home profile path /home/kitsake/.

It can be concluded that when you create a file inside the folder /home/kitsake/ggwp, it will also be reflected inside the folder /root/dota2, and vice versa. However, the actual file is not located in /home/kitsake/ggwp but in the symlink that serves as the source, in other words, /root/dota2, as shown in the example above.

Make sure the symbolic link

Make sure your symbolic link is actually created on your server and of course, it can be used, you can see it by looking at the contents in the directory.

# pwd
# ll
# cd ggwp
# ll
Make sure symbolic link
Make sure symbolic link

Yes, in the image I attached, it has a different symbol compared to regular directories. In its interpretation, the 'ggwp' folder points to the folder /rppt/dota2/.

Remove symbolic link

After creating a symlink, you should also know how to remove that symlink if there is a need for it. Here, I am using the 'unlink' command. Call the unlink function to remove the specified FILE.

And below is an example of how to use the unlink function:

# pwd
# ll
# unlink ggwp
# ll
Remove symbolic link
Remove symbolic link

Yes, you have successfully removed the symbolic link with just one step, haha

Closing statement

And that concludes my post on How to Make and Remove Symlink in Linux RHEL 7. I hope this post can serve as a reference for you when you want to pamper programmers without having them make extensive changes to their code. You can be the hero in that situation, hahaha.

Maybe that's all I can share with you guys, hopefully, this article will be useful.

Thank You 

Bangkit Ade Saputra
Bangkit Ade Saputra At the end of the day, my job involves people. we're complicated, we're always changing, we have millions of things going on in our lives, and changing jobs is always a big decision.

Post a Comment for "How to Make and Remove Symlink in Linux RHEL 7"