WSL:登陆指定Linux子系统(在安装了多个Linux子系统的情况下)
To login you need to run:
wsl -d
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 with the username of your choice:
NEW_USER=
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
Finally, login to the second instance of Ubuntu again:
wsl -d
Need Help? Open a discussion thread on GitHub.
How to install multiple instances of Ubuntu in WSL2