How do I remove a symlink?
Asked Answered
T

7

118

I just created the symbolic link sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib and am wondering: how can I get rid of it if I wanted to? How would I do this?

Tbilisi answered 28/10, 2011 at 17:48 Comment(1)
Related: Remove a symlink to a directoryBunker
O
153

Remove it just like you would any other file: rm /usr/lib/libmysqlclient.18.dylib. rm will remove the symlink itself, not the file the link is pointing at.

Oneidaoneil answered 28/10, 2011 at 17:50 Comment(1)
for me on macOs it the command line jus stopped waiting for something I gave up waiting and deleted the symlink from Finder.Pedant
K
58

You can use the unlink command: unlink /path/to/sym/link

Deleting the file within Finder also works fine. It will have a little shortcut icon on it.

Kalinda answered 11/1, 2013 at 21:12 Comment(0)
I
15

Just run:

rm /usr/lib/libmysqlclient.18.dylib

This will remove the file (i.e. the symlink).

Alternatively you may use unlink:

unlink /usr/lib/libmysqlclient.18.dylib
Inimitable answered 15/7, 2015 at 1:52 Comment(0)
K
4

Somehow I had a symlink to a non-existing folder. I don't have any idea how it happened, but to remove it I found the easiest way was open in Finder and manually delete it. I came to this decision after an hour wasted on trying to delete it with the Terminal.

Kenleigh answered 7/4, 2018 at 23:6 Comment(0)
O
3

I had a link pointing to a folder with short-name "testproject": you make that with this command

ln -s /Users/SHERIF/repo/test  testproject

I had to change the folder name to something else for some reasons when I run the command unlink pointing to the old folder directory it didn't work.

I tried to only unlink testproject to remove the short-name so I can re-use the same name again and link to the newly named folder. it did work fine for me.

Orsa answered 27/3, 2017 at 8:5 Comment(0)
J
1

You could remove that link with sudo rm /usr/lib/libmysqlclient.18.dylib

Johan answered 28/10, 2011 at 17:50 Comment(1)
That ought to come with some risk assessment. What could get the file deleted (zapped, wiped out, gone to the eternal bitfields) and not just the symbolic link? Just two extra characters?Bunker
T
0

To remove a symlink, you can use the unlink command in the terminal. For example, if the symlink is called mysymlink, the command would be unlink mysymlink.

Tiresias answered 27/12, 2022 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.