Permissions and users

Linux commands: passwd

Learn how the Linux passwd command changes your password through an interactive prompt, and how root can set another user's password without the old one.

8 minute lesson

~~~

Change your own account password interactively:

passwd

The program reads passwords without displaying them. Depending on the system and authentication setup, it may ask for the current password before accepting a new one:

Terminal showing passwd command prompting for old password with cursor at input field

An administrator can start the interactive flow for another account:

sudo passwd username

Do not put the new password on the command line. Command arguments may appear in shell history or process listings, and the common passwd interface does not take a plaintext password as a second argument.

If a password change is rejected, read the exact message. Systems can enforce minimum length, history, complexity, account state, or directory-service policy. Repeatedly trying small variations does not diagnose which rule failed.

Changing a local Unix password may not change an SSH key, cloud identity, Apple ID, or organization directory password. First identify which authentication system the login actually uses.

Administrators can inspect account-aging information with platform-specific tools such as chage on Linux. Locking, expiring, or resetting an account is security-sensitive: verify the username and keep another administrative session available when working remotely.

Try it on a disposable local account or lab machine. Confirm the command prompts interactively and that no password appears in history.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →