Managing account passwords
If you remember correctly, the
passwd command enables us to alter the password for the user who is now logged in to the system. In addition, we are able to change the password for any user account on our system by running the
passwd command while logged in as root and providing the username. However, that is only one of the capabilities of this command.
Locking/unlocking user accounts
The ability to lock and unlock a user account is one feature of the
passwd command that we have not yet discussed. You can use this command to do either of these things. There are lots of different use cases where you need to accomplish something like this. For example, if a person is going to be gone for a lengthy period of time, you might want to lock their account so that it is inaccessible to other users during that time.
-l option when you want to lock an account. For example, to lock the account for the
packt user, we use the following command: