Cannot su to Admin on Big Sur
Solution 1:
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 meanssu
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)".
Solution 2:
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