How To Change Passwords In Linux?

Passwords are used to authenticate users or different entities in order to access some services, resources, or operating systems. As a secure and modern operating system, Linux provides passwords for a long time from its startup. Event some Linux distributions provide passwordless login for a better and easy user experience it is not recommended for security reasons. Linux passwords can be managed with different actions like changing a user password, changing another user’s password, forcing a password reset, locking password, unlocking password, checking password security, etc.

Change User Password

One of the most used operations is changing the current user password. There are different ways like GUI, command-line interface, or 3rd party tool. In the following example, we use the passwd . Just running the passwd command without any parameter or option changes the current user password. First, the current password is asked and then a new password is asked two times for the confirmation and to prevent mistyping-related errors.

$ passwd
Change User Password

Change Another User Password

By default, the passwd command is used to change the current user password but can be also used to change another user’s password. In order to change another user password, we should provide root privileges by using the sudo command and provide the username.

$ sudo passwd ahmet

Force Password Reset

Linux password management provides a password change or resets function but it is generally not applied. We can force the user to the password reset. When the user is forced for the password reset the next time the user login he/she is asked to change the password. The -e option is provided to the passwd command with the user we want to force to reset password.

$ sudo passwd -e ahmet

Lock Password/Account

A user account or password can be locked with the passwd command by providing the user name and -l option. The user account is not removed or deleted and only becomes inactive unless unlocked.

$ sudo passwd -l ahmet

Unlock Password/Account

Already locked accounts can be unlocked via the passwd command. The -u option is provided to the passwd command in order to unlock or activate an existing account.

$ sudo passwd -u ahmet
See also  Linux chage Command - Change Password Expire Date

Leave a Comment