How do I change a user password in Ubuntu Linux?

last updated in Categories , ,

We recently switched from Windows server operating system to Ubuntu Linux operating system at work. I am a developer by profession and do not know much about Linux. I need to change the sftp/ssh user account password on Ubuntu. How do I change a user password in Ubuntu Linux?

Introduction – Your Ubuntu Linux account information stored in a file named /etc/passwd and encrypted password in /etc/shadow. This page explains to you how to change the Ubuntu Linux root and user account password using the passwd command line.

How to change a user password in Ubuntu

  1. Open the terminal application by pressing Ctrl+Alt+T
  2. To change a password for user named tom in Ubuntu, type:
    sudo passwd tom
  3. To change a password for root user on Ubuntu Linux, run:
    sudo passwd root
  4. And to change your own password for Ubuntu, execute:
    passwd

How to change a root (superuser) password in Ubuntu

Firstly, open a terminal window. If you want to change the password for remote Ubuntu server, log in using the ssh command:
ssh user@ubuntu-server-ip
ssh vivek@ubuntu-webserver-1

Type ‘sudo -i’ at the command prompt, and Enter key:
sudo -i
Type the current user password and press Enter key. Finally type NA command and press Enter to change password for root user:
passwd

How to change a root user password in Ubuntu Linux
Change password for root user on Ubuntu

Similarly, you can type the following command on Ubuntu to change the root user password as well:
sudo passwd

How do I change the user account password on Ubuntu?

Again open a terminal window. Type the following command to change the password for regular Ubuntu user account named jerry:
sudo passwd {userNameHere}
sudo passwd jerry ## <-- change password for jerry ##
sudo passwd vivek ## <-- change password for vivek ##

How to change a user password in Ubuntu Linux
How to change the user Password in Ubuntu Linux

Conclusion

This quick tutorial taught you how to change the Ubuntu Linux root user and other user account password using the passwd command. You must root user to change the password for all other users, however users can change their password without sudo access. For more info see this page.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.