CloudsArk
Commands Linux

What Is the passwd Command in Linux?

Learn what the passwd command does in Linux, how its syntax works, and when to use it.

What Is the passwd Command in Linux?

Introduction

The passwd command changes passwords and manages password lock state. It is useful for beginners, Linux administrators, DevOps engineers, and RHCSA students because it solves practical terminal tasks.

What the Command Does

Use passwd to work with the specific Linux object it manages. Before changing anything, identify the target and run a read-only check when possible.

Basic Syntax

passwd OPTIONS USER

The syntax includes the command, any options, and the target object.

Common Options

  • -S: show password status.
  • -l: lock password login.
  • -u: unlock password login.

Practical Examples

passwd
sudo passwd student
sudo passwd -S student
sudo passwd -l student

Verification command:

sudo passwd -S student

Example output:

student LK 2026-05-30 0 99999 7 -1 (Password locked.)

When to Use This Command

Use passwd to set passwords, force password changes, and lock or unlock password-based login. Pair it with chage when password aging policy matters.

Common Mistakes

  • Assuming password lock blocks SSH key authentication.
  • Unlocking an account without checking expiry or aging settings.
  • Using weak temporary passwords on shared systems.

Quick Reference

passwd
sudo passwd student
sudo passwd -S student

Summary

The passwd command is safest when you understand the target, choose the right option, and verify the result with a separate command.