locoboy
locoboy

Reputation: 38910

How do I remove a symlink?

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?

Upvotes: 128

Views: 155439

Answers (7)

Alec Rust
Alec Rust

Reputation: 11305

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.

Upvotes: 63

Pip
Pip

Reputation: 1172

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.

Upvotes: 4

Kuru Tulin
Kuru Tulin

Reputation: 1

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.

Upvotes: 0

Sherif SALEH
Sherif SALEH

Reputation: 97

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.

Upvotes: 3

Mohammad Anini
Mohammad Anini

Reputation: 5220

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

Upvotes: 15

Marc B
Marc B

Reputation: 360592

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.

Upvotes: 163

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

Upvotes: 1

Related Questions