Want to Change Your Linux User Password? Here is the Guide For You

change linux password

Want to Change Your Linux User Password? Here is the Guide For You.

If you have recently switched from Windows or macOS to Linux, you will likely need some time to adjust to the command-line interface. On Windows and Mac, you can easily change your password, login screen, and also rename files, but when it comes to Linux or Ubuntu, you need to learn some commands for doing such mere operations. 

Also read: Things to do after installing Kali Linux – Most Important

This article discusses how to change Linux passwords for users and groups. Moreover, you don’t need root privileges to change the password on Linux and Unix-like operating systems. 

How to Change Your Linux Password?

To change your Linux password, you can use a simple “passwd” command, but does that allow you to change the password for any user? 

Well, not really. 

A normal user can change the password for their account, but a superuser or a root user can change the password for any account. Likewise, passwords for groups can be changed by their respective group administrator and root user. 

The “passwd” command also allows you to change account information, such as the full name of the user, user login shell, or password expiry date and interval. 

Some Catchy Line To Grab Your Attention

Get Our Prime Content Delivered to your Inbox for Free!! Join the Ever-Growing Community… Right Now.

1. How to Change User Password on Linux?

When you want to change the password for your account as a user, you must remember your old password. Without the old password, you cannot change the password for the account.

However, you can change the password of any account as a superuser or root user without having to remember the old password. It is helpful when you want to change the password of accounts/users who no longer remember their password. 

Once you have the old password, here is how you can change the user password on Linux. 

  • Open the terminal window on your Unix or Linux system.
  • To change the password of the account you are logged in, type the following command –

    passwd

    Change user password on Linux

  • Now, you will need to enter your old password, and if it is correct, you will be prompted to enter a new password for your account. 
  • When entering the new password, ensure you correctly type it as there is no confirmation prompt. This means you don’t get a chance to be double sure if you have correctly entered the password.
  • Once the password is changed, it is stored in the /etc/shadow directory in the encrypted format. 

The password of your Unix/Linux account is now changed successfully. You can check the status of your password change using the following command, 

passwd -S username

In the later section of our article, we will discuss analysing the password status. It is helpful to know if the users have recently changed their password and how long before they changed it.

Also read: How to check the version of Linux? Check Linux Version


2. How to Change a User’s Password as a Root or Superuser?

As a superuser of the Linux OS, you can change the password of any user account without having their old password. Meanwhile, you can also delete an existing user or add a new one. Which also why normal users should not be granted root privileges.

To change the password of another user, it is necessary that you first log in as a root user or superuser. You can do this operation without logging out of the current workstation and using a simple command.

Here is how to change the password of the user as a root or superuser,

  • Open the terminal window on your Linux or Unix-like operating system.
  • Type the following command to enter as a root,

    sudo -i

  • Once done, type the following command and the username to initiate the password change request.

    sudo passwd username

    Change password on Linux as a root user

  • Now, enter the new password and retype the same for confirmation for that particular username.

That’s it. The Linux password for the particular user is now changed. Just to remind you, this password is to be shared with that specific user before you forget, or they won’t be able to log in. 

Also read: How to Delete Files and Directories in Linux – Simple Guide


3. How to Change Root User Password on Linux?

If you are doing some personal work on your Linux OS, it becomes essential that your credentials are safe and only you can access your workstation. On Linux, changing a root user password is not a big task and can be done just like a regular user. Except, you need to use the “sudo” command alongside. 

Here is how to change the superuser or root password on Linux,

  • Login as a root user on your Linux desktop and open the terminal window.
  • Type the following command,

    sudo passwd

    Change Root Password on Linux

  • Enter the old password you used to log in to the root account and enter the new password.
  • Once the password is changed, it is stored in the /etc/shadow directory in the encrypted format. 

It is important to be careful while changing the root or superuser password; it is hard to recover the OS and its data if you forget it.

Also read: How To Zip A Folder In Linux Distribution Using Compression Levels


4. Force Users to Change Password on their Next Login

As an administrator or root user, you might sometimes want users to keep changing their passwords to tackle any breach. Asking them can be sometimes not taken seriously, and this is where you can force them to change their password on their next login.

Whether logging in using the CLI or GUI, users will have to go through a mandatory change password session before logging in when using the following steps as a root user. 

  • Log in as the superuser and open the terminal window.
  • Use the following command,

    sudo passwd -e {username}
    $sudo passwd --expire {username}

  • This will immediately expire the password for the current username.
  • Once the password expires, you can find the system generated information about it as represented below,

    passwd: password expiry information changed.

When you expire the password, the user will see a prompt to change their password using the old and new passwords on the login screen. This is one of the best ways to ensure you are keeping your systems safe by regularly changing the passwords. 

Also read: Best & Free Screen Recorders for Linux/Ubuntu


5. How to Change Linux Password for Group Users

Changing passwords for group users is similar to changing the password for a regular user. The difference here is extra arguments that can be used to remove or restrict the password for a group and use a group name instead of a username. 

Here is how to use the “passwd” command on the group users,

  • Open the terminal window on your Linux OS.
  • Type the following password,

    passwd -g group name

  • Here, -g specifies a group and can be used along -r and -R arguments. 

The -r argument is used to remove the current password for the group, and the -R argument is used to restrict the named group to all users. It is important to note that if you remove the current password for the group, any user or member can access it easily without using any password. 


How to View Status of Linux Password Change?

Once you have changed the password for your user account or others, you might want to know if the changes are applied. Viewing the status of the password change is also helpful to a superuser as it allows you to view if the password for a certain user was changed recently and how long before was it done.  

Here is how to view the status of password change on Linux,

  • Open the terminal window on your Linux OS.
  • Type the following command,

    passwd -S username

  • Now, you can find a string of information which looks something like this,

    username P date age 9999 7 -1

Let’s discuss each of the arguments used in this string,

View Password Status on Linux

Username: It is specific to the user whose password status we are viewing

P: This argument specifies the password status for this particular user. If it is set to “P”, it determines the user has a usable password. However, if this argument specifies “L” and “NP”, it signifies a locked password and no password. 

Date: The date of the last password change

Age: The minimum age for the user password

9999: The maximum age (default to 9999) for the user password

7: Number of days before the password expires

-1: Number of days after a password expires before it is locked

Also read: How to Use Clubhouse on PC | Windows, Mac, and Linux


Frequently Asked Questions

How to change a Linux user password without an old password?

If you want to change the Linux user password without the old password, you can change it in the role of the superuser. If you are in a group, you can request your root user to change the user password.

How to set a password for a user on Linux?

To set a password for a user on Linux, you can use the “passwd” command and specify the username. Since the user does not have an existing password, you will be directly asked to enter the new password.

Is changing the user password on Ubuntu the same as on Linux? 

Yes, there is not much difference, and you can use the same “passwd” command to change the user password. Moreover, the root user also has the same privileges and does not require a password to change to a new one. 

Before you leave…

Get Our Prime Content Delivered to your Inbox for Free!! Join the Ever-Growing Community… Right Now.

Wrapping up: How to Change Your Linux User Password

Changing your Linux user password is pretty simple by using the “passwd” command. You can use the same command and arguments to change the password for the root user and group users and force change the password on the next login. 

We hope to have helped you with how to change your Linux user password. If you have any questions, do let us know in the comment section. 

Leave a Reply

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

Previous Post
Microsoft Word Not Opening on Mac

MS Word Not Opening on Mac? Here is the Fix

Next Post
Linux for Programmers

11 Best Linux Distro For Programmers

Related Posts
Popup subscribe Form Tiny Quip

Connect

Some Catchy Line to Grab your Attention

Get Our Prime Content Delivered to your Inbox for Free!! Join the Ever-Growing Community… Right Now.

Total
0
Share