About the root user
The user named root, or superuser, is a special user account in UNIX-like operating systems that has unrestricted read and write privileges to all areas of the file system in OS X 10.10 or earlier. However, in OS X 10.11 or later, the root user’s write access to certain areas of the file system is restricted.
See the Apple Support article About System Integrity Protection on your Mac.
The root user is disabled by default. Although you can enable it, it’s recommended that you avoid logging into a Mac as the root user, either locally or remotely. Instead, use the
sudo command-line tool to perform tasks that require root user privileges. You can restrict access to
sudo by adding users to the /private/etc/sudoers file.
WARNING: Use extreme caution if you log in as the root user. You can lose data, damage the system by moving or deleting critical files, or cause other problems that can only be solved by reinstalling macOS. If you log in as the root user, always log out after completing your task, log in as an administrator, then disable the root user.
To learn how to enable the root user, see the Apple Support article How to enable the root user or change the root password on Mac. When you create a password for the root user, choose a complex password that contains alphanumeric and special characters, to prevent the password from being compromised.