DEV Community

Cover image for How to add or change the password for a user in Linux?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to add or change the password for a user in Linux?

Originally posted here!

To add or change a password for a user in Linux, you can use the passwd command followed by a space and the username in Linux.

For example, let's say you want to add or change the password of the user john, you can use the passwd command like this,

# Add or change the password for a user
sudo passwd john
Enter fullscreen mode Exit fullscreen mode
  • This will show you a prompt where you can set or change the password for the user, in our case john.
  • Sometimes you may need to use the sudo command before the passwd command to obtain the correct privileges to execute the command.

Try executing the above command in this online terminal to see the result.

Feel free to share if you found this useful 😃.


Discussion (0)