How do I remove a symlink?

MacosSymlink

Macos Problem Overview


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

Macos Solutions


Solution 1 - Macos

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.

Solution 2 - Macos

You could also use the unlink command: unlink /path/to/sym/link

I believe just deleting the file within Finder works fine also, it will have a little shortcut icon on it.

Solution 3 - Macos

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

Solution 4 - Macos

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.

Solution 5 - Macos

Somehow I had a symlink to a non-existing folder. Have no 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.

Solution 6 - Macos

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlocoboyView Question on Stackoverflow
Solution 1 - MacosMarc BView Answer on Stackoverflow
Solution 2 - MacosAlecRustView Answer on Stackoverflow
Solution 3 - MacosMohammad AniniView Answer on Stackoverflow
Solution 4 - MacosSherif SALEHView Answer on Stackoverflow
Solution 5 - MacosPipView Answer on Stackoverflow
Solution 6 - MacosBasile StarynkevitchView Answer on Stackoverflow