Skip to content

Root Password on a Mac: Enable or Change It, and Change Passwords in Terminal

Updated 5 min read

Updated: 11 October 2026 · Applies to: macOS 27 Golden Gate (man pages checked on 27.0.1, Apple documentation); Linux part tested on Ubuntu 26.04.1

A Mac has no default root password: according to Apple, the root user is disabled by default. For admin tasks you use sudo in Terminal, and it asks for your own administrator password, not a root password. If you really need the root account, set its password in Directory Utility (Edit > Enable Root User or Edit > Change Root Password) or with dsenableroot in Terminal. To change your own login password in Terminal, run passwd.

Use sudo instead of the root account

Apple says it is safer to use sudo than to enable the root user, because root can change files your Mac needs, and undoing that may mean reinstalling macOS. Most tasks work like this:

sudo command-to-run     # one command as root, asks for your password
sudo -i                 # a root shell (login shell), type exit to leave
sudo -s                 # a root shell that keeps your shell

According to Apple, only administrator users can use sudo. From a standard account, switch to an administrator first with su adminname.

Enable root or change the root password with Directory Utility

  1. Open Directory Utility with Spotlight, or in the Finder choose Go > Go to Folder, enter /System/Library/CoreServices/Applications/ and open it from there.
  2. Click the lock and enter an administrator name and password.
  3. To turn root on, choose Edit > Enable Root User and enter the password you want for root. If root is already enabled, choose Edit > Change Root Password instead.
  4. To use it, log out, then at the login window enter the user name root and the new password (click Other if the login window shows a list of users).
  5. When you are done, choose Edit > Disable Root User. Apple recommends always disabling root after the task.

Enable, change or disable root in Terminal

According to the dsenableroot manual page on macOS 27:

  • dsenableroot enables root. It uses your user name and asks for your password and then the new root password.
  • dsenableroot -d removes the root passwords and disables the root user again (it asks only for your password).
  • To change the root password from Terminal, disable root and enable it again with a new password: dsenableroot -d, then dsenableroot.

Avoid the -p and -r options that put passwords on the command line: they end up in your shell history.

Change your own Mac password in Terminal

Run passwd. According to its manual page, it asks for your current password first, then for the new password twice; nothing is shown while you type.

passwd

Two things to know before you use Terminal for this:

  • Keychain: your login keychain password normally matches your login password. According to Apple, changing the password in Users & Groups settings changes the keychain password to match. If your Mac asks for the keychain password after a change, enter your previous password.
  • Apple Account: this is the password you use to unlock the Mac, not your Apple Account (iCloud, App Store) password.

The settings method, according to Apple for macOS 27: choose Apple menu > System Settings, click Users & Groups, click the Info button next to your user name, click Change, fill in Old Password, New Password and Verify, then click Change Password.

An administrator can set another local user’s password in Terminal with sudo dscl . -passwd /Users/alex, which prompts for the new password. According to the dscl manual page, the user’s old password is still required when FileVault is enabled, so if FileVault is on, use Users & Groups for other accounts. If you forgot your own password, follow Apple’s If you forgot your Mac login password.

Change a password in a Linux terminal

Linux uses the same passwd command. This is the real output on Ubuntu 26.04 when a user changes their own password:

$ passwd
Changing password for alice.
Current password:
New password:
Retype new password:
passwd: password updated successfully

As root (or with sudo) you set another user’s password without knowing the old one:

# passwd alice
New password:
Retype new password:
passwd: password updated successfully

On Linux, sudo passwd root sets the root password the same way. More options, such as chpasswd for scripts, are in How to Change a User Password in Linux (passwd and chpasswd). For the root password of a Ucartz VPS you can also use the client area: see How to change the VPS root password using Ucartz client area?.

Change a password in a Windows terminal

In a Command Prompt opened as administrator, net user alex * changes the password of the local account alex; according to Microsoft’s net user reference, the asterisk makes Windows prompt for the password instead of showing it. For a Windows Server you reach over Remote Desktop, see How to Change Your Password in a Remote Desktop (RDP) Session on Windows Server.

Official documentation: Apple: How to enable the root user or change the root password on Mac, Apple: Change the login password on Mac, Apple: If you need to update your keychain password.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Дали Ви помогна овој одговор?

Still stuck? Open a ticket