6

I am trying to edit /System/Library/LaunchDaemons/com.apple.taskgated.plist on OS X El Capitan. The file permissions are

-rw-r--r-- 1 root wheel 601 17 Nov 2015 com.apple.taskgated.plist

My first try was sudo vi (filename) and then use w! after editing but vi still reports read only status.

My second try was to use nano with sudo - same problem.

My third try was sudo su then edit the file - same problem.

My fourth try was vi (filename), write as temporary file then sudo cp (temp file) (filename) - operation not permitted.

I would like to know a) how to fix the problem and b) what I have misunderstood - I thought that I have full root access via sudo or sudo su and root has write permission on this file...

koan
  • 163
  • 1
  • 1
  • 6

4 Answers4

12

Unless you have already disabled System Integrity Protection, the /System directory tree will not be writable even by root.

Issue ls -lO /System (capital letter 'oh', not zero); if you see restricted, SIP is protecting that directory tree.

Solution (from the linked answer):

  1. First boot into recovery mode (Command-R during boot)
  2. In the terminal, issue csrutil disable
  3. Reboot to normal mode. You should see that SIP is no longer blocking write access.

If you later want to restore SIP, just use csrutil enable in recovery mode.

Bill G
  • 103
user4556274
  • 1,440
1

my guess is that you were using vim on a mac to edit a system file. Try using nano instead. It worked for me.

dev4life
  • 127
0

Make sure the file is not open by another process that might be blocking it.

lsof +D /System/Library/LaunchDaemons/
0

Check if all folders leading to the file you want to edit exist! That is what had happened to me :)

vim ~/some_folder/some_non_existing_folder/file.txt