2

I am using WSL on Windows 11 with Ubuntu 20.04 LTS (Focal Fossa).

During the installation process, I think I entered the command ubuntu --install (in VSCode), but I ran into an issue during the installation. The terminal opened, asking for a Linux user and password, but then it closed as some other application started or something.

Since I never got the chance to set my default user's password, I opened CMD, and, if I remember correctly, used the command ubuntu config --default-user root. Then I returned to the Ubuntu shell and entered a command to reset my Linux password.

At this point I had not even used my VSCode. However, when I open VSCode, it still seems to be in the root user's account.

I used mkdir to create a folder without realizing I was still in root, as shown below:

root@Lokrheim:~/folder# 

When I type exit, the shell just closes, as if it is exiting the application rather than the root user's login. No matter what I do, my VSCode still remains as a root user.

How can I access my non-root user in Ubuntu on WSL?

0

1 Answer 1

2

there was an issue upon restarting as the shell had opened asking for a Linux user and password but the shell closed as some other application started or something

It sounds like you have an aborted installation, which probably left you without a default user at all. In this case, WSL defaults to using the root user (regardless of the distribution).

Option 1: Reinstall Ubuntu on WSL

If you've just recently installed and don't have any files that you don't mind losing in Ubuntu, then the best solution is going to be to simply reinstall the distribution so that it completes properly.

To do so, open a regular (non-Admin) PowerShell terminal, and ...

wsl --unregister Ubuntu
ubuntu.exe

(Side-note: If this was Ubuntu 22.04, I'd recommend using either ubuntu.exe install --gui=none or ubuntu2204.exe install --gui=none as per this answer.)

That will pretty-quickly complete the installation (since it doesn't actually have to re-download the Store package) and get you back to the point where it asks for a default username and password.

Option 2: Recreate user manually

If you do have files and need to recover without a reinstall, see this answer and look for the section on "Creating a new "default" WSL user without reinstalling". Also use the next step (Setting the default WSL user) to reset the default after creating one.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .