Home / How To / How to manage account password in Linux

How to manage account password in Linux

There are some Linux commands that you should know about to manage account passwords effectively. Knowing how to set a password for a user, enforce validity policies, and provide user account information is an important part of securing your multi-user Linux user system. In this article we cover some of the most useful password management commands.

How to change your password

The most important command you need to know is the command passwd . Even if you do not have root privileges on a Linux system, you can still change your own office password with the command passwd – unless, of course, you are not locked out of the account because you forgot your password.

  $ passwd 

You must enter your new password twice.

How to change an account password

If you have root privileges, you can use the passwd command to change the optional account password in the system. This is a common task for Linux administrators, as you need to run the command passwd when adding a new user to the system. Until you cannot, the user cannot log in.

To add a new user to your system:

  $ sudo useradd newuser 

After adding a user to the system, or when you need to reset a user's password, run the command passwd followed by the username of the account you want to edit.

  $ sudo passwd newuser 

How to change the root account password

in the same way as a regular account password. You can either log in to the root account and run the passwd command:

  # passwd 

Or use sudo but enter root as the user you want to change:

  $ sudo passwd root 

Force a user to change their password

You can force a user to change their password the next time they log in with the -e option for the command passwd .

  # passwd -e newuser 

When the user ( newuser in our example) logs in again, the system will ask them to create a new password before allowing them to continue.

How to unlock and unlock an account

If there is a time when you have to lock a user's account ̵

1; whether it is temporary or permanent – you can use the -l (lock) option in the command passwd to achieve this.

  # passwd-l newuser 

Locking an account will completely disable it, even if someone tries to log in with the correct password. To restore functionality to the account, simply issue the same command with a -u (unlock) flag instead:

  # passwd -u newuser 

View Account Information with Finger

Command finger gives a practical way (pun intended) to see account information. However, it may not be installed by default on your system. To install it on Ubuntu, run the following command:

  $ sudo apt install finger 

Use the tool by just typing finger and the account you want to see information about:

  # finger newuser [19659005] The  finger  output can tell the user's name, the path to their home directory and their default shell, including information. 

Use chage to manage the password's initial settings

The command chage can be used to see the last time a user's account password was changed and when it is set to expire. Use the -l option to view this information:

  # chage -l newuser 

You can also set a password date to expire. There are a few options to do this, but such a way is with the -M flag. For example, to solve a 90-day password:

  # chage -M 90 newuser 

Source link