Skip to content

Linux commands: passwd

A quick guide to the `passwd` command, used to change a user's password

Users in Linux have a password assigned. You can change the password using the passwd command.

There are two situations here.

The first is when you want to change your password. In this case you type:

passwd

and an interactive prompt will ask you for the old password, then it will ask you for the new one:

When you’re root (or have superuser privileges) you can set the username of which you want to change the password:

passwd <username> <new password>

In this case you don’t need to enter the old one.

The passwd command works on Linux, macOS, WSL, and anywhere you have a UNIX environment


→ Get my Linux Command Line Handbook

→ I wrote 17 books to help you become a better developer:

  • C Handbook
  • Command Line Handbook
  • CSS Handbook
  • Express Handbook
  • Git Cheat Sheet
  • Go Handbook
  • HTML Handbook
  • JS Handbook
  • Laravel Handbook
  • Next.js Handbook
  • Node.js Handbook
  • PHP Handbook
  • Python Handbook
  • React Handbook
  • SQL Handbook
  • Svelte Handbook
  • Swift Handbook
...download them all now!

Also, JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025

Bootcamp 2025

Join the waiting list