FactorPad
Build a Better Process

Linux passwd Command Summary with Examples

Linux passwd allows you to change user passwords.
  1. Purpose - Learn what passwd is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with passwd.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux passwd, 80 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / passwd-command.html


An ad-free and cookie-free website.


Examples of the Linux passwd Command

Beginner

Learn to change user passwords at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux passwd Command Summary with Examples (3:45)

Video Script

The Command and Why You Need It

Our eightieth word, or command to memorize is passwd from our category Users.

passwd allows you to change user passwords.

Common Linux passwd Options
-options description
-h, --help Print help screen
-e, --expire Set an account's password to expire immediately
-l, --lock Lock the user account

Recall from recent videos (tutorials) on su and sudo we logged in as another user and temporarily became a superuser to perform administrative functions, and now we'll learn about passwords.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The passwd command has 15 options, and the argument is the login (name).

Like most commands, help is available with double-dash --help. Non-superusers can only change their own password by using passwd optionless and they are prompted for the old password and the new. The superuser changes passwords for others and can use -e to expire a password, or even -l to lock an account and -u to unlock it.

So why is passwd an important command? Well, everyone needs to understand policies on password resets, password complexity and frequency of changes. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's say it's Friday and Jennifer's password expired according to policy, and she's setting a new one. I've used the su command (from video 78) to pretend I'm her with the passwd Enter.

jennifer: $ passwd Changing password for jennifer. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully jennifer: $ _

Enter the current password and then the new one it will confirm twice.

Okay, hit exit to leave.

jennifer: $ exit $ _

And I'm no longer Jennifer now.

Now, fast forward to Monday and after a really good weekend Jennifer forgot her password. So as the administrator, I'll set up a new one using sudo passwd jennifer.

$ sudo passwd jennifer Enter new UNIX password: _ Retype new UNIX password: _ passwd: password updated successfully

Enter a new one, which I will supply to her.

And last, so she selects her own password, I'll run a sudo passwd -e jennifer.

$ sudo passwd -e jennifer passwd: password expiry information changed.

And when she logs in, she'll be required to change it. Okay, very good.

A Final Tip

Okay now you know how to use passwd. And you know the syntax for commands, options and arguments.

One last tip about the passwd command. So I recommend reading the man page here as it's a particularly easy one to grasp in only 5 minutes.

Okay, thanks for visiting today. I hope this was a helpful introduction to the passwd command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

I suggest using multiple modes of learning here. Check out the video while reading the text and key in the code. That's the fastest way to learn.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / passwd-command.html


linux passwd examples
etc passwd
linux passwd
passwd linux
passwd command
linux change user password
linux set user password
linux password
passwd file
man passwd
linux etc passwd
sudo password
linux password file
linux change password
change password linux
pwd linux

A newly-updated free resource. Connect and refer a friend today.