How to Change User Password in Linux

You may already know about the password command, which enables users to change their password on a Linux system.

Regular users on Linux can only change their password.

But the root user (Super User) can change any user account password in Linux and there are no restrictions.

If you want to change the root user password, you must have sudo privileges to do so.

If you forgot the root password on CentOS/RHEL systems. Navigate to the following link to reset it.

For security reasons you should change your password frequently or at least once a month. You must use hard to guess password, your password length is at least 10-15 characters (The combination of password should be Alphabet Upper and Lower case letters, numbers and Special Characters (Symbols)).

This method is common for all Linux distributions and works fine.

General syntax for the passwd command

passwd [Options] [UserName]

This tutorial will help you to change your own password, root user password and other users’ password.

  • How to Change your own password
  • How to change other users’ password
  • How to change root user password

1) How to Change your own password in Linux

A normal user can change the password for his own account by simply entering the password command on their terminal.

# passwd

Changing password for daygeek.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

When you type a password, nothing is displayed on the screen, which is the expected behavior in Linux/UNIX.

2) How to change the password of other users

A user must have sudo privileges to change other user’s password on Linux.

To change the password for another user account, type the password command and the username you want to change.

For example, to change the password for the “Tanisha” user, run the following command. You will be asked to enter the new password twice.

$ sudo passwd tanisha

[sudo] password for daygeek
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

If you want to reset the user’s password in a single command, use the following format: This only works for Red Hat based systems.

$ sudo echo "new_password" | passwd --stdin renu

3) How To Change the root User Password In Linux

The user must have sudo privileges to change the root user password on Linux. If you have sudo privilege, you can either change the password directly or switch it to the root user and then change it.

If you want to change the root user password directly from the sudo privilege user, use the following command format.

$ sudo passwd root

[sudo] password for daygeek
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

After switching to root you can run the passwd command directly to change the root user password without any arguments.

$ su -
# passwd

Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

If you want to reset the root user password in a single command, use the following format:

# echo "new_password" | passwd --stdin root
Changing password for user root.
passwd: all authentication tokens updated successfully.

How to set root user password on Ubuntu based desktop?

By default the Ubuntu based distribution doesn’t have a root user password and you can set it if you need to, but in most cases it is not required.

This is because the default user must have admin access and can perform any actions such as root with help of sudo.

When you run privilege commands, you must add sudo for each command, which requires the associated user’s password rather than the root user’s password.

To set a root password on an Ubuntu based desktop, use the following command:

$ sudo passwd
Enter new UNIX password: Type root password you want
Retype new UNIX password: Retype the root password again
passwd: password updated successfully

Leave a Reply

Your email address will not be published. Required fields are marked *