WSL for Windows

1、安装

VScode官方文档:Developing in the Windows Subsystem for Linux with Visual Studio Code

超详细Windows10/Windows11 子系统(WSL2)安装Ubuntu20.04(带桌面环境)_wsl安装ubuntu20.04-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/weixin_44301630/article/details/122390018

注意,安装之后首次启动 Ubuntu 时,系统会提示你创建一个普通用户账户。使用此账户登录后,我们将设置 root 用户密码。

其他命令:

1、默认使用root角色运行

# 第一个是版本号-windows
ubuntu2204 config --default-user root

查找版本号步骤,请看本子目录参考,里面由教程,这里需要注意的是有可能找不到ubuntu2204,这是因为没有添加到环境变量中,可下载一个everything进行查看。

运行相关的命令:

## 命令介绍-运行环境  ##

# 修改用户(root)密码-wsl
sudo passwd root

# 切换用户(root)-wsl
su root

# 查看wsl列表-windows
wsl -l

# 使用指定用户(root)登录wsl(ubuntu,这个是由上面的`wsl -l`命令获取)-windows
wsl -d Ubuntu-22.04 -u root

# 使用默认账户登录wsl-windows
bash / wsl

# 关闭wsl-windows
wsl --shutdown

参考:WINDOWS下的wsl如何设置Linux子系统默认用户为root - funkergx - 博客园 (cnblogs.com)

2、解决wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理,clash的网络设置。

这个文件在 C:\Users\<UserName>\.wslconfig 中。并添加下列代码,自行创建.wslconfig文件

[experimental]
autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

参考Windows 11 + WSL + VS Code + Rust 环境配置 - LLW_NEU - 博客园 (cnblogs.com)

3、wsl使用docker for windows

首先下载docker desktop Docker: Accelerated Container Application Development

按照如下步骤设置:

就ok了,如果想要局域网互联,请参考:【WSL2】windows 安装适用于linux的子系统,安装 docker 并开启局域网访问!!_哔哩哔哩_bilibili

参考:

配置ssh:在 Windows 上通过 WSL 安装 Ubuntu 22.04 并配置 root 用户登录 (geeksuper.cn)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值