MacOS – Problems with sudo privileges as admin in OSX

administratormacospermissionssudo

I am a admin on my Mac with OSX and I have enabled root user. When I try to use the terminal without typing sudo it does not seem to recognise my privileges as an admin, but it works fine if I type sudo and enter my password.

I also have tried to manually give the sudo privileges in the /etc/sudoers file, but still no luck.

Running an installation through NPM all I get is: "npm ERR! Please try running this command again as root/Administrator."

Why is this and how can I fix it?

Best Answer

This is standard behaviour in OS X, even if you are an Administrator, you will not be able to write to anything under /, apart from your home directory without prefixing your command with sudo. Even if you do use sudo or sudo su - (to gain access to a root shell), you will not be able to make changes to anything under /usr (except /usr/local), /bin. /sbin, /etc, etc... without disabling rootless mode/SIP (System Integrity Protection) from recovery mode. You can disable it using the command csrutil disable. Note that rootless mode is new in OS X 10.11 El Capitan. If you still can't get npm working with sudo, try using sudo whoami and check that it outputs root, and use sudo -u root.

Related Question