4

I try to copy some file to /usr/share folder, but the terminal said that operation not permitted even I do the with sudo.
sudo cp ~/Downloads/kellys.vim /usr/share/vim/vim73/colors/
the result
cp: /usr/share/vim/vim73/colors/kellys.vim: Operation not permitted
When I try to change the permission of this folder, it came with the same problem. I run EI Capitan on Mac. I have google it for a long time,but still confused. How do I solve the problem ?

2
  • Paste exact command that you run and exact output/errors you've got, it'll be easier to understand what you're trying to do.
    – kenorb
    Oct 19, 2015 at 15:33
  • Being you're running El Capitan, it's probably SIP's fault. You can disable SIP, but a better solution is the one in cricket_007's answer below.
    – blm
    Oct 19, 2015 at 16:38

3 Answers 3

4

It looks like the problem you are having is more related to installing Vim colorschemes.

Those can be installed in ~/.vim/colors/.

mkdir -p ~/.vim/colors
cp ~/Downloads/kellys.vim ~/.vim/colors/

And then set it with

:colorscheme kellys

Update
If you really want your file in /usr, then the permissions on that folder are on lockdown and you can't edit it without disabling System Integrity Protection (SIP).

A folder that you can modify, however, is /usr/local/share.

So you can instead do

cp ~/Downloads/kellys.vim /usr/local/share/vim/vim73/colors/
2
  • thanks, but I really want to figure out this problem.
    – doouding
    Oct 19, 2015 at 16:10
  • Let me know if the update helps Oct 19, 2015 at 16:55
1

U need to disable System Integrity Protection.

  1. restarting and use Command ⌘-R on boot
  2. open a terminal and execute command: csrutil disable
  3. restart normally
  4. NOW u can write in /usr dir tree
  5. (optional) restart again, use Command ⌘-R on boot and execute again csrutil enable
2
  • Not sure why it downvoted but this is exactly what I was looking for. I actually needed to add something to /usr/bin not particularly just /usr So, you are back to whole. Thanks.
    – Jiraheta
    Jun 9, 2021 at 0:12
  • Step 5 is NOT optional. Turning off SIP is very risky business. Do not do it unless you know what you're doing. I'm surprised this answer was thrown out so cavalier.
    – hasan
    Sep 13, 2022 at 22:19
0

While the other answer regarding SIP is correct, it's important to know why Apple implemented this security feature in 10.11 and beyond.

It's designed to prevent tampering with critical system processes and (from what you've seen) certain files/locations on the drive. The rootless.conf file defines what/where is protected on the filesystem. What this also means is there is no more 'fix disk permissions' function needed. For a more in depth review of what SIP does, please see this post on Ask Different.

Generally speaking, it's a bad idea to disable SIP permanently. What's better is to disable it in recovery mode, make your changes, then re-enable it. (FYI, resetting the PRAM will turn SIP back on.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .