Deleting the user password can remove the hassle of entering a password every time. Moreover, if a user forgets his password and requests to reset the password deleting the existing password is also necessary. In this article, I will show you how to delete the password of a user in Ubuntu.
Key Takeaways
- Deleting the password using the passwd command.
- Deleting the password using the usermod command.
- Deleting the password from the shadow file.
Requirements
- Having sudo/root privileges is necessary to delete the user password.
Process Flow Chart
Distro Used Throughout the Tutorial: Ubuntu 22.04.1 LTS
Watch how to Delete User Password in Ubuntu
My Ubuntu has a user by the name of “myuser”. In this section, I will show you how to delete the user password of a user who is in this case “myuser” in Ubuntu by using three different methods. You can read our Comparative Analysis of Methods to distinguish between these three methods and best pick one for your need. At first, I will use the passwd command to delete the password of the user “myuser”. Steps to Follow > ➊ At first, launch a Terminal in Ubuntu. ❷ Write the following command to delete the user’s password: ❸ Give your password and press ENTER. ❹ (Optional) Now, use the following command to switch user: Now I will use the usermod command to delete the password of the user “myuser”. Steps to Follow > ➊ Firstly, open an Ubuntu Terminal. ➋ Copy the following command to delete the password: ➌ Provide your password and hit ENTER. In this method, I will delete the user’s password from the shadow file. The shadow file is a text file that contains information about the system’s users’ passwords. Steps to Follow > ❶ Press CTRL+ALT+T to launch an Ubuntu Terminal. ❷ (Optional) Back up the shadow file by using the following command: ❷ Write the command below to open the shadow file: ❸ Find the user and delete the password string. ❹ (Optional) At the end, switch the user using the command below: I have deleted the user password using the passwd command, usermod command and shadow file. Here is a comparison between these three methods. Here I have provided some additional information that may be helpful for you. Setting a password expiry date helps to improve the security of user accounts. It also encourages users to change their password regularly. To set the password expiry date, follow the steps shown below. Steps to Follow > ➊ At first, launch a Ubuntu Terminal. ➋ Insert the following command to view the current expiry date: Changing passwords on regular basis is necessary. It protects the accounts from unauthorized access. Here I have shown simple ways to change a user password. Steps to Follow > ❶ Hold CTRL+ALT+T to open a Terminal in Ubuntu. ❷ Copy the following to switch user: ❹ Give the current password and press ENTER. ❺ Type a new password and hit ENTER. ❻ Finally, retype the password and press ENTER to complete the process. In this article, I have shown you how to delete a user password in Ubuntu in 3 different ways with comparative analysis, so that choose which one suits you better. In addition, I have provided some complementary information. Moreover, you should check out the questions below which might be helpful for you. Related Articles3 Methods to Delete User Password in Ubuntu
Method 01: Using the passwd Command to Delete User Password in Ubuntu
sudo passwd -d myuser
If you see “password expiry information changed” in the output, the password has been deleted successfully.
su - myuser
Here you can see, it is not asking for any password.
Method 02: Using the usermod Command to Delete User Password in Ubuntu
sudo usermod -p '' myuser
❹ (Optional) Finally, insert the following password to switch user:
su - myuser
Now you will be able to switch to the user without a password.
Method 03: Delete User Password from the Shadow File in Linux
sudo cp /etc/shadow /etc/shadow.bk
sudo nano /etc/shadow
Here the password string is between the first two colons (“:”).
After deleting the password string, the shadow file will look like this.
su - myuser
You will be able to switch the user without the password.
Comparative Analysis of Methods
Methods
Pros
Cons
Using the passwd command
Using the usermod command
Using the shadow file
Complementary Information
Password Expiry Information Changed in Linux
sudo chage -l myuser
Here, it is showing the “password expires” at “never” and the “maximum number of days between password change” is “99999”. Now I will give a specific expiry date.
❸ Now type the following command to change the expiry date:sudo chage -M 120 myuser
❹ Finally, view the new expiry date using the following command:
sudo chage -l myuser
As you can see, it is showing password expires on “Aug 05, 2023” and “the maximum number of days between password change” is “120”.
How to Change User Password in Linux
su - myuser
❸ Now use the following command to change the user’s password:
passwd
You should see a message saying “password updated successfully”.
Conclusion
People Also Ask