Enable root user on Mac OS

On macOS, the root user is usually disabled by default for security reasons. Enabling the root user should be done with caution, and it’s typically not recommended unless you have a specific need. Here’s how to check if the root user is enabled and how to enable or disable it if needed.

Checking if the Root User is Enabled:

Make sure you are logged-in as a user with administrator level privileges. Open the “Terminal” application, which you can find in the “Utilities” folder within the “Applications” folder.

In the Terminal window, type the following command and press Enter:

sudo dscl . -read /Users/root AuthenticationAuthority

If the above command will display “No such key: AuthenticationAuthority” this means that your root user is currently disabled. If root user is enabled you will see output similar to this “AuthenticationAuthority: ;ShadowHash;HASHLIST:<SALTED-SHA512-PBKDF2,SRP-RFC5054-4096-SHA512-PBKDF2> ;SecureToken; ;Kerberosv5;;root”

Enabling the Root User:

If you need to enable the root user, type the following command and press Enter:

dsenableroot 

You will be prompted to enter your password to confirm the action. After entering your password, you will be prompted to create new password for root. Once you confirm the root password you should receive message similar to this “dsenableroot:: ***Successfully enabled root user.” and the root user will be enabled.

Disabling the Root User:

It’s important to disable the root user when you no longer need it to enhance the security of your system. To disable the root user, type the following command and press Enter:

dsenableroot -d

You will be prompted to enter your password to confirm the action. After entering your password, you will see a message similar to this “dsenableroot:: ***Successfully disabled root user.” and the root user will be disabled.

Please use the root user account with caution, as it has elevated privileges and can make significant changes to your system. Enabling the root user should only be done if you have a specific need, and you should disable it as soon as you are done with the task that required its use.