To login you need to run:
wsl -d <Distribution Name>
Step 5: Setup user accounts
Notice in the above image that the logged in user is a root account. So let's setup a normal user account.
First, while logged in to the second instance of Ubuntu in WSL2 as root, run the below command, replace <USERNAME>
with the username of your choice:
NEW_USER=<USERNAME>
Then, run the following command to create the user account and set the password:
useradd -m -G sudo -s /bin/bash "$NEW_USER" passwd "$NEW_USER"
Step 6: Configure default user
Next, we need to configure Ubuntu to log in as your new user by default instead of root.
To do so, run the below command: paste the entire block of code below into your teminal and press enter.
tee /etc/wsl.conf <<_EOF [user] default=${NEW_USER} _EOF
Step 7: Login as the new user
First, exit the WSL by running logout
, then shutfown the second Ubuntu by running
wsl --terminate <Distribution Name>
Finally, login to the second instance of Ubuntu again:
wsl -d <Distribution Name>
Need Help? Open a discussion thread on GitHub.