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 Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay