Using MacBook Air with Mojave 10.14. While in Bash using terminal app, The SU command ask for password. When I put my user password in it says Sorry try again. My apple password does not work either.
12 Answers
su, without specifying a user name, assumes root, and thus wants the root password, which doesn't exist by default for security reasons (no password means the account is disabled, not that it doesn't require a password).
To enable the root user, all you have to do is set a root password, for example by running sudo passwd root. By default this can only be done from an account with Administrator privileges, and the password it wants is that admin account's password, not the non-existent root password.
But as @DanielB alluded to, the more modern sudo is a better choice for most things than su ever was, and it doesn't require the security risk of enabling the root account. If you want a root shell, use sudo -s.
Assuming that you know what you are doing and have very specific reasons for doing this, as running a shell in SU opens up the possibility that a slip of the finger can delete a lot of things and do considerable damage. That said...
According to the Apple KB document on the Root user in macOS:
The root user is disabled by default.
But it is not difficult to enable, and according to that same document.
- Choose Apple menu () > System Preferences, then click Users & Groups (or Accounts).
- Click lock icon, then enter an administrator name and password.
- Click Login Options.
- Click Join (or Edit).
- Click Open Directory Utility.
- Click lock icon in the Directory Utility window, then enter an administrator name and password.
- From the menu bar in Directory Utility: Choose Edit > Enable Root User, then enter the password that you want to use for the root user. Or choose Edit > Disable Root User.
Once you do that SU will work fine. I would advise that you disable the root user once you are done as enabling the root user leaves your system open for hacking attempts more than usual. Better safe than sorry.