As a regular user, you have a password that safeguards your account, and this account contains all your personal settings and files and therefore requires important protection.
Hence, it is a good practice to change your password consistently to decrease the possibility that someone else gets to recognize your password and can use your credentials to authenticate.
[ You might also like: How to Restrict SSH Access to Certain Users in Linux ]
When changing a user password, make sure it meets the following minimal requirements:
- A password must be strong: at least six or eight characters or more is better.
- Make sure to use complex passwords by mixing letters, numbers, and other characters to make the password as hard to guess as possible.
- Use upper and lowercase letters to make the password harder to crack by an attacker.
- Make sure to avoid using any dictionary word as a password, because attackers use a brute-force password cracker to scan the whole contents of a dictionary, and if your password is in the dictionary, they can easily crack it.
[ You might also like: How to Get Information About Other Linux Users ]
Changing a User Password in Linux
Changing a user password is not that hard, just use the passwd command to change the password of your own account (it could be a root user or regular user).
$ passwd
Now, you need to enter your old password, as this is to prevent others from changing your password. Next, you need to enter the new password twice and make sure that your password meets the complexity rules as explained above; else, it will not be changed.
If you are logged in as a root user, you can change the password of other system users by typing the passwd command followed by the name of the user whose password you want to change.
$ passwd linuxshelltips
It won’t prompt you for the old password, since you are logged in as a root user, you should be able to change the user’s passwords without knowing the old password.
Managing Linux Users with the passwd Command
There are other useful options that you can use while changing a user’s password and they are:
Remove User Password in Linux
Use the -d
argument to remove the password for the specified user account.
$ passwd -d linuxshelltips
Lock User Password in Linux
Use the -l
argument to lock the password for a user account if it is not used for a given period of time.
$ passwd -l linuxshelltips
Unlock User Password in Linux
Use the -u
argument to unlock the user password that has been locked with -l
option.
$ passwd -u linuxshelltips
Force User to Change Password in Linux
Use the -e
argument to force the user to change the password during the next login attempt.
$ passwd -e linuxshelltips
The passwd command is pretty useful to manage system users on your Linux system. It manipulates the user entries in the /etc/passwd file, and the system administrator must have this as a toolkit.