Many users run Linux as their OS of choice because of its numerous advantages as a secure operating system. Any OS, no matter how secure, however, needs a good password.
Linux distros let users create a password for their user accounts when they install the OS. However, changing the password later isn’t exactly difficult either.
In this article, we’re taking a look at how you can change user password in Linux.
Also read: How to rename a file in Linux?
How to change your own user account’s password?
A regular user on your Linux installation can change their password using the passwd utility. All you have to do is type passwd in the terminal and hit enter.
You will then be prompted for your current Unix password, followed by the new password you want to have. Once you’re done, the password on your Linux account would’ve been updated.
How to change any other user’s account password?
The root user or a user with sudo privileges can change other user’s passwords as well. This is done using the passwd utility as well, except this time, we’re going to pass the account’s username as an argument to the command.
sudo passwd accountname
You will be prompted to enter a new password and then confirm the same. Once you’re done, the mentioned username’s account password will be changed.
Also read: How to unzip Tar Gz file?
How to promp a user to update their password on the next login?
Another more elegant way of changing another account’s password is to force them to update their password the next time that particular user logs in to the system.
This is done using the following command.
sudo passwd --expire accountname
When the aforementioned command is executed, the password for the specified user will immediately expire. The next time they log in, they’ll be prompted to enter a new password.
Also read: How to check the list of users in Linux?