Problems with sudo privileges as admin in OSX

5,581

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.

Share:
5,581

Related videos on Youtube

Praise
Author by

Praise

Updated on September 18, 2022

Comments

  • Praise
    Praise over 1 year

    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?

    • Tetsujin
      Tetsujin over 8 years
      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/…
    • Praise
      Praise over 8 years
      @Tetsujin Ok, now I disabled SIP and rebooted. But I still get the same problem. Can´t install via NPM without sudo.
    • Daniel B
      Daniel B over 8 years
      Please use something like Homebrew. It’s easy to manage and won’t break your system.
    • Praise
      Praise over 8 years
      @DanielB Use Homebrew instead of NPM you mean?
    • Daniel B
      Daniel B over 8 years
      No. Use Homebrew to install NodeJS, which includes NPM.
  • Praise
    Praise over 8 years
    I did just that and it still does not work. I did just as you describe. Why is that?
  • tomlester
    tomlester over 8 years
    It may be a different issue... let me think about it.