# 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.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-09-24 | Topics: [CLI](https://flaviocopes.com/tags/cli/) | Canonical: https://flaviocopes.com/linux-command-passwd/

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:

```bash
passwd
```

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

![Terminal showing passwd command prompting for old password with cursor at input field](https://flaviocopes.com/images/linux-command-passwd/Screen_Shot_2020-09-04_at_07.32.05.png)

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

```bash
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
