0

After installing Big Sur on my iMac, I cannot become an Admin from Terminal.

I've used a dialogue within the System Preferences menu to set a password for the Admin user.

In Terminal, when I try to su, I am asked for the Admin's password. The password is not accepted.

How can I become an Admin from Terminal?

2
  • Are you trying to su to an account named "admin", or to root, or something else? Commented Aug 28, 2021 at 2:09
  • I'm just using the 'su' command without arguments to become the superuser.
    – bob
    Commented Aug 28, 2021 at 3:54

3 Answers 3

4

I think you're a bit confused about "Admin" vs root. Your normal account is probably an admin account (i.e. it's a member of the admin group, and is therefore allowed to do things like change system-wide settings in System Preferences). I think what you're trying to do is become root (aka superuser). On macOS, the root account generally doesn't have a password (and shouldn't). See my answer here for more about the distinction.

Given that, the short answer is that if you're already logged in as an administrator, you should use sudo -s to open an interactive shell as root (or sudo somecommand to run a single command as root).

If you're logged in as a standard (non-admin) user, you have to promote to root in two steps: first, use su someadmin (where someadmin is the name of an admin account you know the password to) to promote to administrator, and then use sudo -s as above to become root from there. Note that both commands will ask for a password, and in both cases it's the password of the admin account you're going by way of.

More explanation: in macOS, both the su and sudo commands can be used to switch between accounts, but they have a couple of significant differences:

  • su asks for the password of the account you're switching to. Since root doesn't normally have a password, this means su can't be used to switch to root. On the other hand, sudo asks for the password of the account you're switching from, and then checks a config file (/etc/sudoers) to see if your account is allowed to do that (which, by default, is set to "if you're in the admin group or are root, you can do whatever you want").

    These differences are why, if you're logged in as a standard (non-admin) user, you need to use both to promote from a standard user to an admin and then to root.

  • su defaults to running an interactive shell session as the user you're switching to, but you can run a single command with its -c option. sudo is the reverse -- it defaults to running a single command, but its -s option tells it to open an interactive session.

P.s. there are a couple of related questions: "What is the difference between the sudo and su command?" and "sudo vs su (as non-root user)".

1

On Mac Os X the default command to be admin isn't su but sudo. When you want to keep the admin privileges in terminal, you can use

sudo -s

If you want use su you can add the root password with the command

sudo passwd root
0

There is no user called "admin". But there is a Group called Administrators. You need a username which is a member of that group - probably the first username you created. Check with System Preferences. After that the steps you need are:

  • Login with the username that is an Administrator

  • In Terminal:

    sudo su

  • and provide the password of the username.

1
  • Why is this wrong?
    – Gilby
    Commented Aug 28, 2021 at 7:40

You must log in to answer this question.

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