Delete /usr/bin/emacs - Operation not permitted

9

2

I was about to reinstall Emacs from railwaycat/emacsmacport when I stumbled upon /usr/bin/emacs, /usr/bin/emacsclient and /usr/bin/emacs-undumped.

angrybacon@sandman ~/ $ ll /usr/bin/emacs*
-r-xr-xr-x 1 root wheel 26929904 Dec  3 07:35 /usr/bin/emacs
-rwxr-xr-x 1 root wheel  3201184 Dec  3 07:36 /usr/bin/emacs-undumped
-rwxr-xr-x 1 root wheel    36928 Dec  3 07:36 /usr/bin/emacsclient

I'm trying to delete those binaries with no success.

angrybacon@sandman ~/ $ sudo rm -f /usr/bin/emacs*
rm: /usr/bin/emacs: Operation not permitted
rm: /usr/bin/emacs-undumped: Operation not permitted
rm: /usr/bin/emacsclient: Operation not permitted

I've tried GNU's rm and removing schg flag, still no luck.

Also, are those shipped with default Mac setups?

Same issue with /usr/share/emacs/ and /usr/share/info/emacs*.

Mathieu Marques

Posted 2015-12-28T13:12:31.157

Reputation: 193

Please [edit] your question to include the file permissions of the 3 files. – DavidPostill – 2015-12-28T13:20:53.527

@DavidPostill Added permissions. Are those the kind you were referring to? – Mathieu Marques – 2015-12-28T13:28:35.320

The files are owned by root. sandman has only execute permission. Try using sudo to delete them. – DavidPostill – 2015-12-28T13:32:34.423

@DavidPostill Sorry my post was uncomplete, I already tried. – Mathieu Marques – 2015-12-28T13:33:11.967

Answers

9

It's the new "system integrity" feature in OS X. Even as root, you can't do everything. Good news is... you can disable it.

  1. Reboot into recovery mode (boot while holding down command + r keys.
  2. Open the terminal (Utilities -> terminal)
  3. run the following in the terminal:

    csrutil disable; reboot
    

Hit return, your mac will reboot and you'll be good to go.

tomlester

Posted 2015-12-28T13:12:31.157

Reputation: 133

3seems quite excessive ... is there really no way to do this outside of rebooting and recovery mode? how did emacs get god status? – user391339 – 2017-08-01T21:05:56.520