How To Set or Change User Password In Linux?
Linux passwords are used to authenticate users. Linux passwords was hold in
/etc/passwd file with other user related information like default shell, home directory path etc. Now in modern Linux distributions holds passwords in
/etc/shadow file which have restricted access. This file holds user passwords as hash values with salt. Hashing and salting makes passwords more secure.
Change Current User Password
To change a user password we need password change privilege. For currently logged user we can change passwords just like below.
- passwd command will start change process for current user which is root.
- New password: is asking new password and will not be printed to the screen for security reasons.
- BAD PASSWORD is prompted because I have entered easy to crack password. For your productions systems please chose strong passwords.
- Retype new password: is asking to enter same password for second time to avoid mistakes.
- passwd: shows that password update process is completed successfully.
Change Different User Password.
To change other user password we need to be root user. We will provide the username to the
passwd command in order to change user password. In this example we will change the password of user
$ passwd test
Changing password for user test.
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
- This is very similar to previous password change operation.
Change Group Password
Linux operating system provides group for flexible privilege management. All users may have one or more groups. These groups also have passwords too. We can also change these password. We will use
gpasswd command in order to change group password. In this example we will change the group ismail password.
$ sudo gpasswd ismail
How To Set or Change User Password In Linux? Infografig