• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Change User Password in Linux

Written by Admin, Updated On May 18, 2019
password, terminal
Change User Password in Linux

This tutorial describe how to change user password in Linux. We will also cover how to change or set password of another users using sudo privileges.

You can use passwd command to change user password in Linux distribution. Password related information are stored at /etc/shadow file. If you are a normal user in your system then you can only change password of your own account. Only root account or users with sudo privileges can change password of another users.

Change Your User Password#

To change password of your own user account open terminal and run following command without any options:

passwd
Change User Password in Linux

It will prompt you to enter current password. Once it will be authenticate successfully you will be asked to enter new password and confirm password.

At next login you can use your new password instead of old one.

Change Another User’s Password#

As we mentioned above that only root or sudo users can change another user’s account password. Following is the basic syntax to change another user’s password.

sudo passwd [username]

For example, assumes that you are logged in as a user with sudo privileges.

Now to change another user’s account password run the passwd command followed by the username. Here we want to change the password for demouser then run the following command:

sudo passwd demouser

You will be prompted to enter and confirm the new password:

Output
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Force User to Change Password at Next Login#

If you want to force users to change their account password at next login then you can it by adding expiry option. By default, passwords are set to never expire. Pass the --expiry option along with passwd command as given below:

sudo passwd --expiry demouser

This command will immediately expire a user account’s password.

Once the demouser will try to login next time using old password it will force to set new password as given below:

Output
WARNING: Your password has expired. You must change your password now and login again! Changing password for demouser. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Connection to 192.168.43.125 closed.

After that once the user sets a new password the connection will be closed

Change Group Password#

You can change password of group using -g option with passwd command. For example, to change the password of group sales run following command.

sudo passwd -g sales

Conclusion#

In this guide, you have learned how to change own and another user account passwords. It’s recommended that to change your password frequently and use a unique password for each account for security purpose. Get more information about the passwd command at the Linux passwd man page.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to List Users in Linux
Next Article   How to Setup UFW Firewall on Ubuntu 18.04

Related Posts

  • How to Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Python 3.11 on Debian 11
    How to Install Python on Debian 11 January 25, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook