How to Change Password in Ubuntu Linux

how to change password in ubuntu linux

Suppose you were using a Windows server and have recently switched to Ubuntu, and you may have many questions, one of them being how to change a user password in Ubuntu? How to change the root password in Ubuntu? There are many ways to change a user’s password in Ubuntu without knowing the password. In this guide, we’ll cover exactly how you can change a password in Ubuntu once you buy Linux VPS hosting and start using it.


Where Are Ubuntu Passwords Located?

Ubuntu Linux account information is stored in a directory called the /etc/passwd file with encrypted password hashes stored in the /etc/shadow. Now how to change the user password in Ubuntu to know where they are stored? Below, we’ll be doing just that.


How to Change a User Password in Ubuntu?

You can change your Ubuntu password using terminal. Thus, start the terminal by pressing Ctrl+Alt+T.

To change the password of a user named Moe in Ubuntu, type:

sudo passwd Moe



To change the password for the root user in Ubuntu Linux, type:

sudo passwd root



To change the password for the current user in Ubuntu, type:




How to Change root Password in Ubuntu (Superuser)

The first step is to open a terminal. If you’d like to change the password of a Remote Ubuntu server, sign into the server using the command ssh, for example:

ssh user@ubuntu-server-ip
ssh moe@ubuntu-webserver-1




Use the ‘sudo-i’ at the terminal, and Enter:

sudo –i



Enter the password for your current user and press Enter. After that, type the passwd command. Press Enter to change the password in Ubuntu 20.04 terminal for the root user: passwd

In the same way, you can enter the following command in Ubuntu to alter the root user’s password too:

sudo passwd



How to Change the User Password in Ubuntu?

Once again, open the Ubuntu terminal window. Enter the following command and modify the password for the regular Ubuntu user account named Moe:

sudo passwd {userNameHere}

sudo passwd Moe



How to Delete a User’s Password in Ubuntu Linux?

Suppose you have a user called Joe, and you want to remove their password; you’ll have to type in the following command to remove the password of the allocated user:

sudo passwd -d joe




sudo passwd –delete joe



Once you press Enter, you’ll see a confirmation message that simply says:

Passwd: Password expiry information changed.

To create a new password after removing the password, type:

sudo passwd -d joe



In addition, you can set password expiration for any user in Ubuntu Linux. To do so, type in the following command in the terminal and hit Enter.

sudo passwd -e joe sudo passwd –expire joe



After login, users will be required to reset their passwords if they choose the -e/ –expire option:

Account or password is expired, reset your password and try again

New password:

Retype a new password:



In this short and useful tutorial, we discussed how to change passwords in Ubuntu Linux. We talked about changing the root password as well as a user’s password in the Ubuntu terminal. You need to be a root user in order to alter the password of all other users. However, users are able to change their passwords with sudo access. Just change your password soon after you buy Linux VPS Server.

2 thoughts on "How to Change Password in Ubuntu Linux"

  1. youtube says:

    If somme one desires to be updated with hottest technologies afterward he
    must be goo to see this web page and be up to date all the

    1. aredeshir behbood says:

      Dear client,

      Thank you for your kind comment.

Leave a Reply

Your email address will not be published.