DEV Community

Cover image for Reset WSL password
Susan Githaiga
Susan Githaiga

Posted on • Edited on

Reset WSL password

Uh oh! Forgot your WSL password? Don't sweat it! I'll get you back in and running in no time.

Important notes before proceeding:

  • Back up all your WSL data: If possible, back up your important files and data from your WSL before proceeding, as this process may involve making changes that could potentially lead to data loss.
  • Understand the risks: Resetting a password involves granting temporary root access to your WSL system. Be cautious and follow the steps carefully to avoid unintended consequences.

Follow these steps to reset your forgotten WSL password:

Steps to Reset Your WSL Password:

Open Windows Command Prompt:

Type in wsl -l

Image description

This command will list all the Linux distributions you have installed.

Select the Linux Distribution:

From the list, select the Linux distribution you want to change the password for and type:

wsl-distribution config --default-user root

NB: Type it in lowercase and remove all spacing, hyphens (-), and full stops (.).

Image description

This command will allow you to change the password of your sudo user.

Now, Open Your WSL Terminal:

You will be logged in as the root user by default.

Image description

Type in: passwd username to Change the Password

Image description

Restore the Default User:

Once the password is successfully changed, go back to the Windows Command Prompt and set the default user to its previous state by typing in:

wsl-distribution config --default-user your-username

Image description

Now, you can use your new password to perform sudo operations on your WSL.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more