'su root failed on Mac

I tried to use the command "su root" on Mac OS Monterey version 12.3.1, but response was always Sorry, is there any possible reasons other than the wrong password?

I checked the link [ https://stackoverflow.com/questions/70699857/linux-shell-command-su-authentication-failed ] as this man did before. According to the specification, it says that [root and users in group wheel can run anything on any machine as any user], the belonging of me myself is wheel absolutely. See attached image. However, I did not succeed after trials.

enter image description here enter image description here

Thank you so much ! Best Regards, Juan K.N



Solution 1:[1]

When you do su root, you need to input root password.

To become root, we usually do sudo su -, then input your own password.

Solution 2:[2]

In macOS the root user is DISABLED by default. Also note, macOS is not Linux! You should really use sudo as @Philippe suggested.

If you want to enable the root user there are two methods:

  1. In a Terminal window:

    trev@macmini8 [/Users/trev] $ sudo su -
    Password:
    macmini8:~ root# passwd
    Changing password for root.
    New password:
    Retype new password:

  2. Choose Apple Menu (top left) > System Preferences
    Choose Users and Groups
    Click Login Options
    Click Join
    Click Open Directory Utility
    From the menu bar in Directory Utility
    ... Choose Edit > Enable Root User
    ... Enter the password that you want to use for root

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Philippe
Solution 2 Trev