Reset forgotten password in Ubuntu WSL: A comprehensive guide

5 months ago - 2 MIN READ - jidanmaharjan1

Education
Reset forgotten password in Ubuntu WSL: A comprehensive guide

If you are using windows with WSL Ubuntu and forgot the password, resetting it would be a hassle. However, you can reset the password without reinstalling the distro or losing the data. This is a step-by-step guide to reset a forgotten password in Ubuntu WSL running on windows and not a guide to cause harm in any form. Please follow this guide if you:

  • Forgot password without use for long period

  • Setup random password accidentally

Here is the Step-by-Step guide to reset your Ubuntu WSL password running on windows.

  1. Open CMD or PowerShell as an Administrator.

    • Click Start or press windows button

    • Type cmd or powershell to search

    • Right click and select Run as administrator.

  2. List your installed Linux distributions

    wsl -l -v

    Example:

     NAME                STATE           VERSION
    * Ubuntu    running         2
  3. Launch WSL as root user

    Type exact name of your ubuntu distribution (Ubuntu in my case it might be Ubuntu-24.0)

    wsl -d Ubuntu -u root
  4. Figure out your username (if you know your username, skip this step)

    ls /home 
  5. Reset your password

    passwd yourusername

    Replace yourusername with above output or your known username

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

    Enter new password and complete the process.

Hope you have successfully reset your password. If you have any problem, feel free to contact me.

AD SECTION
AD SECTION

Trending

Fix High CPU usage (winlogui.exe)

10 months ago - 3 MIN READ

How to setup weak password in Ubuntu

9 months ago - 2 MIN READ

Fix files being tracked even after adding to gitignore

9 months ago - 2 MIN READ

Setup GIT using SHH: An Ultimate Guide

8 months ago - 2 MIN READ

Cypress: Generate reports of automated tests

8 months ago - 2 MIN READ

Use cypress tags (grepTags): An Ultimate guide.

8 months ago - 2 MIN READ

Subscribe to Newsletter !