After installing AlmaLinux or migrating from CentOS to AlmaLinux, most users will eventually run into the need to do some user account management, such as adding a new user account or resetting a password.
If you or one of the other users of an AlmaLinux system forgets the password to their account, there's a simple way to reset the password from either command line or GUI. The same steps can also apply if it's simply time to change your password or you want to force another user's password to expire and change.
There are several scenarios that you might encounter that cause you to reset your password.
- You need to change a normal user or the root account's password
- You want to force a user to change their password
- You have forgotten the root account password
In this guide, we'll be covering the step by step instructions for problems 1 and 2 mentioned above. If you need help resetting your system's root password, see our other guide for recovering a root password on RHEL.In this tutorial you will learn:
- How to change user or root password via command line
- How to change user password via GNOME GUI
- How to force a user's password to expire and be reset
|Category||Requirements, Conventions or Software Version Used|
|Other||Privileged access to your Linux system as root or via the |
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
How to change user or root password via command line
passwd command is used to change a user password on AlmaLinux. If you need to change the password for the user you're currently signed into, just execute the command by itself.
If you want to change the password of the root account, you'll first need to elevate to the root user before running the command.
# passwd OR $ sudo passwd root
To change the user password for some other account that you're not already logged into, only the root user has proper permissions to do that. Just specify the user account you wish to change after your
passwd command. In this example, we'll change the password for user
# passwd linuxconfig Changing password for user linuxconfig. New password: Retype new password: passwd: all authentication tokens updated successfully.
How to force a user's password to expire and be reset
Rather than changing a user's password manually, we can also force a user's password to expire. This way, the user is prompted to set a new password the next time they login. In the example below, we will set the
linuxconfig user's password to expire.
# passwd -e linuxconfig Expiring password for user linuxconfig. passwd: Success
Now, we see the following prompt when trying to sign in from either GUI or command line.
To set the user account's password to expire in the future, we can use the
chage command. For example, to make the password expire in 30 days, we'd use the following command.
# chage -M 30 linuxconfig
How to change user password via GNOME GUI
If you have the default GNOME GUI installed on AlmaLinux, it's very easy to change the password for a normal user account on AlmaLinux.
- Open the "Users" menu of GNOME settings by searching for it in the activities menu.
- You'll need to elevate your permissions in order to manage the user accounts. Click on the "unlock" button and enter your root password to proceed.
- Now you will be able to click the password box and enter your new desired password.
That's all there is to it. You can close the Users menu when done.
In this guide, we saw how to change the password for a normal user account and root account on AlmaLinux through command line and GNOME GUI. We also learned how to set a user's password to expire, which will prompt them to change passwords the next time they log in. This is a basic task that most users will find they need to do at some point, and AlmaLinux makes the process quick and easy.