WSL:登陆指定Linux子系统(在安装了多个Linux子系统的情况下)

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.

How to install multiple instances of Ubuntu in WSL2

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Win10的Linux子系统(Windows Subsystem for Linux,简称WSL)是一种在Windows系统上运行Linux程序的一种机制,它提供了与传统的虚拟机不同的操作方式,可以在Windows环境下直接运行Linux命令和工具。 尽管WSL是一个非常方便的工具,但它也存在一些潜在的危害。首先,由于WSL在Windows内核之上运行,因此它的安全性不能与原生的Linux系统相提并论。如果恶意软件能够在WSL中运行并控制系统,那么它有可能影响到整个Windows系统,导致更大的安全问题。 其次,WSL是一个相对较新的技术,仍然存在一些稳定性和兼容性的问题。尽管微软在不断改进和更新WSL,并且用户可以从Microsoft Store下载并安装最新版本的WSL,但仍然可能会遇到一些不稳定的情况,导致应用程序无法正常工作或系统崩溃。 另外,WSL仅支持部分的Linux发行版和软件包,无法完全取代原生的Linux环境。一些特定的Linux应用程序和功能可能无法在WSL中运行,这对于那些对Linux工具依赖较多的用户和开发者来说可能是一个限制。 最后,WSL对于新手用户可能存在一定的学习曲线。虽然WSL提供了Linux命令行界面,但对于不熟悉Linux操作的用户来说,学习和使用WSL可能需要一些时间和精力。 综上所述,尽管WSL是一个方便的工具,但也存在一些潜在的危害和限制。用户在使用WSL时应当注意安全性问题,及时更新和升级WSL版本,并了解WSL的兼容性和稳定性情况,以便更好地利用它的优势,避免潜在的问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值