Change User Password in Ubuntu
Forgot your own password or have to reset it for others? Here's how to change the password in the Ubuntu command line.
Changing passwords is really simple in the Ubuntu command line. Just use the passwd
command and you can change the password for your account or other user accounts.
A few things to note:
- You should have access to the system as a root or non-root user
- You need to be root or have sudo access to change passwords for other users
This article is not about resetting your server's root password if you cannot access it. That's an entirely different topic.
Change the password for your own account
If you are logged in as a non-root user, you can change the password for this account easily.
Just enter the command passwd
:
passwd
It asks for the current password. Enter this password.
You probably already know that the Linux terminals show nothing on the screen while you type the password.
Enter the password correctly, and it will ask you to enter the new password twice. You should see the success message if you successfully type the new password twice.
abhishek@learnubuntu:~$ passwd
Changing password for abhishek.
Current password:
New password:
Retype new password:
passwd: password updated successfully
That's it. That's how you change passwords in the Ubuntu command line.
Change password for other user accounts
As a sysadmin managing an Ubuntu server, you may require changing other users' passwords.
The steps are pretty much the same as you saw earlier. You just have to specify the username with passwd
command this time.
Do note that you must be a root user or have sudo access to change the password for others.
So either change the user to root or use sudo like this:
sudo passwd username
It will ask you to enter the new password straightaway. You are resetting the password after all and you may not know the password for other users even though you are the admin.
root@learnubuntu:~# passwd abhi
New password:
Retype new password:
passwd: password updated successfully
Once you have reset the password, you can inform the user and give them the new password. A good practice would be to advise the user to change the password immediately after login.
That's it. Short, sweet, and simple. Enjoy Ubuntu!