How to Change Password in Linux? Root User and User Account

Changing the password on the root user and other user accounts helps to prevent unauthorized access to the system. It controls the system, including the ability to install, modify, and delete software, and access sensitive files. The purpose of changing the password on the root user and other user accounts in Linux is to improve the security of the system. 

This guide will demonstrate methods to modify the password on the root user and normal (non-root) user account in Linux:

Method 1: Change Passwords on Root User

The root user has complete control over the operating system. To change the root user’s password, use “sudo” before the “passwd” command. The sudo provides temporary root privileges to change the root password. 

Here is the command regarding the root user:

$ sudo passwd root

The output requires entering the new password for the root user twice to confirm it. If the password meets the minimum complexity requirements (8 characters), the root password will be changed.

Note: If you are logged in as the root user, then there is no need to use the “sudo” keyword.

Method 2: Change Passwords on a User Account (Non-Root Users)

In Linux, the “passwd” command is utilized to change the password for a currently logged-in user and specific account. 

Current Logged-in User

To change the password for a regular user account, simply run the “passwd” command in a terminal:

$ passwd

The above command acquires the current password for the user account and then asks to enter the new password twice to confirm it. After inputting the new password, the password is updated successfully.

Changing the Password of any Other User

The “passwd <username>” command is utilized for changing the password for other users in Linux. For instance, change the password of the user “roger” as below:

$ sudo passwd roger

The output shows that the password of user “roger” has been updated.


To change the password on the root user and user account in Linux, execute the “sudo passwd root” and “sudo passwd <username>” commands, respectively. These commands require the existing password of the machine for authentication. After that, set new passwords according to requirements. 

This article has explained all possible methods to change the password on the root user and user account in Linux.