CloudsArk
Commands Linux

passwd Command Examples in Linux

Practice useful passwd command examples for everyday Linux administration and troubleshooting.

passwd Command Examples in Linux

Introduction

These examples show practical ways to use passwd on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.

Example 1: Basic Usage

passwd

This is the simplest form of the command and is a good starting point before adding options.

Example 2: Common Admin Task

sudo passwd student

This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.

Example 3: Useful Option

sudo passwd -S student

This option helps narrow the result, change behavior, or handle a more realistic target.

Example 4: Real-World Scenario

sudo passwd -l student

Use this pattern when the task moves beyond a single basic command.

Example 5: Verification

sudo passwd -S student

Example output:

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

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
sudo passwd -l student
sudo passwd -S student

Summary

Good passwd usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.