How to delete symbolic links in CentOS Linux servers ?

How to delete symbolic links in CentOS Linux servers ?

Symbolic links : What are they ?
Symbolic links act like pointers to another file which saves hardisk space on server. They are also called softlinks as by creating a simple link to the file can just save time and space on sevrer. If you delete a Symbolic link then it is similar to delete the real file or directory. These links have different inode numbers.

How to remove symbolic links :
You can remove symbolic links using two caommands which are given below :
1). rm : it will delete each file including symbolic links.
2). unlink : it will remove single file with symbolic links.


Examples to remove symbolic links :
First start with symbolic links, let us create a soft link for trial purpose.
-----
# ln -s /usr/test.conf host
-----

You can list soft link to check it's appearence.
-----
# ls -l host
-----

Now, to delete above created symbolic link run this command.
-----
# rm host
OR
# unlink host

-----

Now we will see how to delete Symbolic Link Directory ?

First create a softlink directory throguh this command.
-----
# ln -s /usr/lib linkhost
-----

You can list soft link to check it's appearence.
-----
# ls -l linkhost
-----

Now, to delete above created symbolic link run this command.
-----
# rm linkhost
OR
# unlink linkhost

-----

Note: whenever deleting a symbolic link to a directory, do not end the target with a ‘/’ character else it will give an error.
Author
bhawanisingh
Views
4,796
First release
Last update
Rating
0.00 star(s) 0 ratings
Top