Skip to content
Log In Sign Up info@muvcloud.com

The Commands

sudo passwd root

sudo first asks for your own password, then passwd asks twice for the new root password. Nothing appears on screen while you type. A message that the password was updated successfully confirms the change.

For your own account, no sudo is needed:

passwd

It asks for the current password first. As root or with sudo you can set another user's password without knowing the old one:

sudo passwd deploy

These steps are written for the current Ubuntu LTS releases. They work the same on Debian. There the installer either disables root and sets up sudo for the first user, if the root password was left empty, or sets a root password; in the second case sudo may be missing, so you become root with su - and run passwd.

Is the Root Password Locked?

sudo passwd -S root

The second field is the status: L means locked, P means a usable password is set, and NP means no password. Ubuntu locks the root password by default, and many cloud images do the same: you log in as a normal user or as root with an SSH key, and use sudo for admin work.

Why a Locked Root Password Is Fine

  • Keys are stronger: an SSH key cannot be guessed the way a password can.
  • Nothing to steal: bots that try passwords for root on SSH have nothing to find.
  • Audit trail: admin work done with sudo is logged under each person's own name.

Set a root password only if you need it, for example to log in at the server console in your provider's control panel. If you do, use a long random password such as one from a password manager, never a dictionary word. The examples on this site use STRONG_PASSWORD as a placeholder.

Lock It Again

sudo passwd -l root

-l locks the password only. It does not stop root from logging in with an SSH key, and sudo keeps working for admin users. sudo passwd -u root unlocks it again.

Root Login over SSH

Whether root may log in over SSH is set by the PermitRootLogin line in /etc/ssh/sshd_config or in a file under /etc/ssh/sshd_config.d. The OpenSSH default, prohibit-password, allows root with a key but not with a password. sshd uses the first value it reads for a setting, and on Ubuntu the .conf files in that folder are read before the rest of the main file, so check both places. Before changing it to no, make sure a sudo user works, as described in how to create a sudo user. Then:

  1. Edit the setting and check the file with sudo sshd -t.
  2. Restart SSH, keeping your current session open.
  3. Log in from a second terminal before closing the first.

The restart command differs between releases; how to change the SSH port lists it for each one.

If You Forgot the Root Password

  • You still have a sudo user: log in as that user and run sudo passwd root. The old password is not needed.
  • You have a root SSH key: log in with the key and run passwd.
  • You have no working login: use your provider's control panel. Most providers offer a password reset, a rescue mode that starts a separate system from which the server's disk can be mounted and the password changed, or a reinstall. Take a snapshot first if the panel allows it.

Password Rules

Depending on the PAM settings, passwd may refuse a new password that is too short or too simple when you change your own. Root may be warned but allowed to set a weak password for another account, which is no reason to do so. For SSH logins, keys remain the better choice; see how to use PuTTY to SSH into a server.

Troubleshooting

  • Authentication token manipulation error: passwd could not write the new password; a common cause is a root file system that is read-only or full. Check free space with df.
  • User is not in the sudoers file: your account has no sudo rights; log in with an admin account.
  • Passwords do not match: the two entries differed; run the command again.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations