I'm running into a root permissions issue on OS X 10.8.3. This is manifesting itself in various forms.

It became clear after trying to execute a self-update of MacPorts. The following issue https://stackoverflow.com/questions/15780321/macport-selfupdate-fails-code-23-xcode-command-line-tools-are-installed highlights the error seen.

XCode and the XCode command line utilities are installed and the root user is enabled.

The key thing is that I can't make changes as root as root doesn't seem to have the right permissions. I've tried chown'ing and chmod'ing anything in /etc and /etc/local but I always get "Operation not permitted"

I've followed all the normal resolutions. Disk Utility -> Repair Permissions, Enable/Disable the root user, change the root user p/w, power-cycle the machine.

bash-3.2$ chmod 775 base.tar
chmod: Unable to change file mode on base.tar: Operation not permitted
bash-3.2$ ls -la
total 129744
drwxr-xr-x  10 root  admin       340  8 Apr 15:17 .
drwxr-xr-x   3 root  admin       102  8 Apr 12:38 ..
-rw-r--r--   1 root  admin   9453803  8 Apr 12:30 PortIndex
-rw-r--r--   1 root  admin       512  8 Apr 12:31 PortIndex.rmd160
drwxr-xr-x  24 root  wheel       816 31 Jan 17:30 base
-rw-r--r--   1 root  admin   3594240  8 Apr 15:01 base.tar
-rw-r--r--   1 root  admin       512  8 Apr 15:01 base.tar.rmd160
drwxr-xr-x  51 root  wheel      1734  8 Apr 15:17 ports
-rw-r--r--   1 root  admin  53360640  8 Apr 15:01 ports.tar
-rw-r--r--   1 root  admin       512  8 Apr 15:01 ports.tar.rmd160
bash-3.2$ whoami

At this stage I'm considering re-installing but would prefer to fix this rather than start again.

Output of id is :


output of dscl . read '/Users/root'

bash-3.2$ dscl . read '/Users/root'
AppleMetaNodeLocation: /Local/Default
NFSHomeDirectory: /Users/root
Password: ********
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

PrimaryGroupID: 0
RealName: root
 BUILTIN\Local System
RecordType: dsRecTypeStandard:Users
SMBSID: S-1-5-18
UniqueID: 504
UserShell: /bin/bash
  • One thing to try would be booting from the restore partition (or, DVD, if your computer is 10.6 or older), and running disk utility to repair permissions on the main partition. – Kent May 27 '13 at 8:26
  • Also, make sure the permissions on /etc/sudoers is -r--r----- (440). – Kent May 27 '13 at 8:27
  • The shell doesn't seem to recognize your root-ness, hence the $ instead of #. What's the output of id? – Daniel Beck May 27 '13 at 8:55
  • comments taken onboard and question amended with output – Keith Lynch May 27 '13 at 9:05
  • Why does root have uid 504 on your system? – nohillside May 27 '13 at 9:20

Somehow you created another user named root who does not have root permissions (which might have overridden the default root account), or changed root's user ID. root should have UID 0. Maybe the instructions for Enable/Disable the root user, change the root user p/w you followed were incorrect.

You can try specifying UID 0 explicitly by running sudo as follows:

sudo -u '#0' <command>

dscl is the command-line utility for managing user accounts (among other things). Output of dscl . read '/Users/root' should look similar to this by default:

AppleMetaNodeLocation: /Local/Default
NFSHomeDirectory: /var/root
Password: *
PrimaryGroupID: 0
 System Administrator
RecordName: root
RecordType: dsRecTypeStandard:Users
SMBSID: S-1-5-18
UniqueID: 0
UserShell: /bin/sh

You could try to re-set everything by running dscl . change '/Users/root' 'UniqueID' '504' '0', and hope that sudo works for this. This could break even more though – I've only tested it with the UserShell key.

  • thanks for this. I wasn't able to change with dscl but went through directory utility instead. Got the gist of what you were suggesting. My root user is now '0'. The dscl output has some kerberos info but I assume you filtered this out from your post for security reasons? – Keith Lynch May 27 '13 at 11:30
  • I filtered nothing, but additional entries might not be a problem -- it looks like the UID is the important issue here. It looks like that line might be the hash of the password (my root doesn't have that). – Daniel Beck May 27 '13 at 11:31
  • OK. I've removed some of the superfluous info but as you say it doesn't make much odds. The key thing here was definitely the UID. Anyway thanks again for the help. Much appreciated. I'm a happy user again. Was really fearing having to re-install – Keith Lynch May 27 '13 at 12:00
  • Thanks for this, it fixed my issue. For those just copy/pasting the command, don't forget to change '504' with the actual current id of the root user. Also, don't forget it's UniqueID and not UniqueId (that typo cost me 10 minutes of confusion) – n0pe Jul 23 '14 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.