Deleting symbolic link – operation not permitted

permissionsymlinkterminal

I stupidly used my terminal to create a symbolic link typing this:

sudo ln -s /bin/tcsh tcsh

And now I need to delete it. I tried

sudo rm tcsh

but when I authenticate it tells me:

override rwxr-xr-x root/wheel restricted,compressed for tcsh?

and even if I type y and press enter it tells me:

rm: tcsh: Operation not permitted.

Is there anything I can do to fix this?

Best Answer

It seems you are either trying to remove your original file /bin/tcsh or another tcsh copied to a different path. You can't link /bin/tcsh to tcsh if you are in the /bin folder because that's forbidden.

A soft link of tcsh usually isn't protected by SIP and you have to search for it and delete it. If you somehow managed to copy tcsh to another path, which then prevents a software you are using from working, you may have to delete it there.

To remove a protected tcsh copy, boot to Recovery Mode, disable SIP, reboot to your main volume and remove the link.

  1. Reboot your Mac into Recovery Mode by restarting your computer and holding down Command+R until the Apple logo appears on your screen.
  2. Click Utilities > Terminal.
  3. In the Terminal window, type in csrutil disable and press Enter.
  4. Restart your Mac.
  5. Remove the tcsh copy
  6. Reboot your Mac into Recovery Mode
  7. Click Utilities > Terminal.
  8. In the Terminal window, type in csrutil enable and press Enter.
  9. Restart your Mac.

Link: How do I disable System Integrity Protection (SIP) AKA “rootless” on OS X 10.11, El Capitan? This is also valid for macOS Sierra!