1

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?

5
  • 1
    You don't need the root to be enabled in OS X to use sudo [in fact, it's very much not recommended], any admin can do it by default. What's probably stopping you is System Integrity Protection [SIP] See apple.stackexchange.com/questions/193368/…
    – Tetsujin
    Jan 3, 2016 at 12:46
  • @Tetsujin Ok, now I disabled SIP and rebooted. But I still get the same problem. Can´t install via NPM without sudo.
    – Praise
    Jan 3, 2016 at 13:25
  • Please use something like Homebrew. It’s easy to manage and won’t break your system.
    – Daniel B
    Jan 3, 2016 at 14:56
  • @DanielB Use Homebrew instead of NPM you mean?
    – Praise
    Jan 9, 2016 at 8:53
  • No. Use Homebrew to install NodeJS, which includes NPM.
    – Daniel B
    Jan 9, 2016 at 12:56

2 Answers 2

1

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.

0

Ah.... Being an admin, basically gives you sudo abilities, but you are still not root. I.e. your account is not uid=0. That's the only root user. You have three choices.

  1. Use sudo (like you have been)
  2. You can su to root like: sudo su root -
  3. You can change your UID to 0.

I would recommend #1.

2
  • I did just that and it still does not work. I did just as you describe. Why is that?
    – Praise
    Jan 9, 2016 at 8:56
  • It may be a different issue... let me think about it.
    – tomlester
    Jan 9, 2016 at 23:45

You must log in to answer this question.

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