45

I get this:

Macintosh:8.4 TAmoyal$ su
Password:
su: Sorry
Macintosh:8.4 TAmoyal$

I typed in the password I use for sudo. Why won't this work?

Thanks!

womble
  • 95,029
  • 29
  • 173
  • 228
Tony
  • 4,053
  • 10
  • 34
  • 29
  • because you are not saying to which user you are going to switch to.............. just type : " su - " (yes dash after space without anything else) which by it's understanding got to root..... – Michal Oct 20 '16 at 11:13
  • Don't use su use sudo. If you need a root shell type `sudo -s` or `sudo sh` – hookenz Dec 20 '16 at 20:08

9 Answers9

57

No need to make up a root password. Try sudo su and type your user password.

Marie Fischer
  • 1,943
  • 1
  • 13
  • 13
20

Others have mentioned the details of the root account. However, you don't even need su. Just use sudo -i and you get an interactive root console anyway.

Kamil Kisiel
  • 11,946
  • 7
  • 46
  • 68
4

For su you need to enter root password. For sudo you have to enter your own password and you should be listed in sudoers list. Since you have not set root password or root password is different then your password, su is not accepting your password.

Saurabh Barjatiya
  • 4,643
  • 2
  • 29
  • 34
3

The root password on OS X is disabled; it is not the same as your sudo password.

Say sudo passwd root if you want to make a root password, then su will work as desired. However, make this password differ from your regular user password in the interest of security.

koenigdmj
  • 1,055
  • 7
  • 12
2

The su program expects you to supply the password of the user you become.

The sudo program expects you to provide your own password. The configuration file for sudo controls what you can do with it. With su, knowledge of the other persons password is sufficient.

Using sudo is much better; it doesn't require shared passwords.

Jonathan Leffler
  • 1,035
  • 11
  • 20
2

Based on my experience:

Unless the account you are logged in as has "admin" privileges, you are not allowed to su or sudo.

What I did is create a second account "Administrator" (admin) that has admin privileges then

  • su admin
  • enter admin's password
  • sudo su -
  • enter admin's password

and then the shell I'm in is root.

lexu
  • 922
  • 11
  • 19
1

As the suggestions above mention using sudo su will work. But there is a little bit of history behind this.

First of all, sudo and su are two different commands. sudo requires the password of the current user whereas su requires the password of the target user.

That's why using sudo is preffered as there is no exchange of information.

Based on this all Mac and Ubuntu-based releases are sudo-only, meaning the root account is not active by default. While installing a MacOS or Ubuntu OS, you create a user automatically labeled as part of the sudoers group. However, there is no root account setup. To enable the root user, you need to activate it manually.

To activate the root user run:

sudo passwd root

Next, the output asks to set the password for the root user. Type and retype a secure password, then hit Enter. The system should notify you the password has been updated successfully.

Hope this clears out any confusion there might be.

1

My advice: Modify the file su in /etc/pam.d by inserting the group you intend to enable for su-ing the root to pam_group.so group=admin,<yourgroup> where <yourgroup> may be staff (=standard users) for example.

In order to do this you have to be root already (admin is not sufficient).

techraf
  • 4,163
  • 8
  • 27
  • 44
clemens
  • 11
  • 1
  • Sry - The interpreter ate my brackets and the content between them ;-) Add "staff" after "group=admin," to have success. – clemens Oct 20 '16 at 11:04
1

If you want, you can enable the root user (and set a password) like that.

People will recommend to use sudo instead.

Tolsadus
  • 1,123
  • 11
  • 22