How To Change User Password with passwd In Linux and /etc/passwd File

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/change-user-password-passwd-linux-etc-passwd-file/
PINTEREST
PINTEREST
INSTAGRAM

passwd command is used to change password and provides information about Linux accounts. Normal or root user can change passwords. Normal user can only change his own password in the other hand root can change all users passwords. Passwords related information is stored in /etc/passwd  file. Only password which is stored as hash is stored in /etc/shadow .

Password File

As stated previously user account related information is stored in /etc/passwd . There is information like

  • username
  • password which is X refer to the /etc/shadow file
  • User ID
  • Group ID
  • User ID infor
  • Home directory
  • Command or shell

Here is an example passwd  file.

Password File
Password File

Change Current User Password

We will start with simply changing the current user password. We do not need to provide any user name because the currently logged in user will be used.

Change Current User Password
Change Current User Password

Before entering new password we should provide current password. The new password should be different than existing one

Change Specified User Password

We can change different user than current user. We will specify the user name we want to change password. We should have root privileges. We will run commands with sudo  for root privilege. In this example we will change the user ismail password.

Show Specified User Password Status

Password status is used to show current account password expire or validity dates. We will use -S  option with the user name like below.

LEARN MORE  How To List All Users and Groups in Linux

Show Specified User Password Status
Show Specified User Password Status

Show All Users Password Status

In previous example we have only showed the given user account or password status. We have the chance to list all users. But we need root privileges again. We will use -l with -S like below.

Show All Users Password Status
Show All Users Password Status

Lock Specified User Account and Password

If we need to stop user from logging by locking account. We will provide the account name with the -l  option. In this example we will lock account named john

Unlock Specified User Account and Password

Locking user accounts is a security measure useful if the user will not use for a period of time the system. For example a user will do holiday for two months and the account should be locked for this period of time. We can also unlock the account with the -u option like below.

Delete or Make Empty User Password

We can make user password empty. This will disable password for the given user account. We will use -d option with the username. In this example we will disable password for user john .

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/change-user-password-passwd-linux-etc-passwd-file/
PINTEREST
PINTEREST
INSTAGRAM