Back to course

45. Securing Accounts: Setting Passwords (`passwd`)

Linux Basics: From Zero to CLI Hero

Password Management

New users created with useradd often do not have a password and cannot log in until one is set.

Setting Your Own Password

If run without arguments, passwd prompts the current user to change their own password.

bash $ passwd Changing password for user. (current) UNIX password: New UNIX password: Retype new UNIX password:

Setting Another User's Password (Admin Task)

As root or using sudo, you can set or reset the password for any other user.

bash $ sudo passwd jdoe New password for jdoe: Retype new password for jdoe:

Locking and Unlocking Accounts

If an employee leaves or an account is temporarily compromised, you can lock the account without deleting it using the -l option.

bash $ sudo passwd -l user_to_lock

Unlock the account:

$ sudo passwd -u user_to_lock