Lessons Learned About Windows Subsystem for Linux Accounts, Part 1: Reset — Redmondmag.com

In recent weeks, I have immersed myself in the Windows Subsystem for Linux (WSL) while tackling a project that required a deeper understanding of this environment. Although I have dabbled in Linux before, my experience has been sporadic, leading to a steep relearning curve. Unfortunately, this journey was not without its challenges.

My initial troubles stemmed from a series of self-inflicted errors that could have easily been avoided had I adhered to some fundamental best practices. While it might be a bit embarrassing to share my missteps, I believe that recounting this experience could serve as a valuable lesson for others navigating similar waters.

Understanding the Issue

The complications began when I installed WSL alongside Ubuntu on a lab machine running Windows 11. The installation process requires users to set up a username and password for accessing the Linux environment. In my case, I attempted to bypass this step by using a blank password. This decision backfired, as Ubuntu insisted on a password, leading me to close the Linux window in a misguided attempt to avoid the requirement. Consequently, I ended up with an Ubuntu deployment that lacked a default user account, landing me directly in the Root environment upon opening a new Ubuntu tab in Windows Terminal.

It’s worth noting that best practices advocate for using strong, complex passwords. Microsoft has also emphasized the importance of security in its operations. However, given that I was working with an isolated lab machine, I felt justified in my decision to forgo a password, preferring the convenience of direct access without the need to log in each time I opened a Linux tab.

Resolving the Problem

Through my experience with WSL, I discovered two primary methods to rectify the situation. The first option involves completely resetting the Linux environment and reinstalling the Ubuntu distribution, ensuring a password is set this time. The second option allows you to retain the existing environment while manually creating the necessary user account. Regardless of the chosen method, both approaches enable you to configure the account for auto logon, eliminating the need to enter a password each time.

Initially, my instinct was to remove and reinstall WSL entirely. However, I soon realized that this basic removal did not resolve the issue, as the profiles associated with the original Linux deployment remained intact. Here’s how I successfully navigated the process of removing and redeploying the Linux distribution:

  1. Open Windows Terminal with administrative privileges.
  2. Display a list of existing Linux deployments using the command:
    wsl --list --verbose
  3. Unregister each distribution with the command:
    wsl --unregister 

After unregistering the distributions, the next step is to disable WSL from an elevated command prompt using the command:

dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart

For those using Windows 11, this command should suffice. However, if you’re on an earlier version of WSL, you may also need to disable the underlying virtual machine platform with:

dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart

After completing these steps, reboot your machine. Once the system restarts, open an elevated Terminal session and re-enable WSL with:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Finally, reinstall WSL by entering:

wsl --install

Upon following these steps, I was prompted to create a new default user account, successfully resetting my Linux environment.

In the next installment, I will delve into the process of manually creating the missing account, providing further insights into navigating the intricacies of WSL.

About the Author: Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has authored thousands of articles and contributed to numerous books on various IT topics. Before transitioning to freelance work, he served as a CIO for a national chain of hospitals and healthcare facilities, and has held positions as a network administrator for major insurance companies and the Department of Defense at Fort Knox. In addition to his ongoing IT endeavors, Posey is actively training as a commercial scientist-astronaut candidate, preparing for a mission to study polar mesospheric clouds from space. Follow his spaceflight training on his website.

Winsage
Lessons Learned About Windows Subsystem for Linux Accounts, Part 1: Reset -- Redmondmag.com