乐趣源

WSL 命令简单总结

list

wsl -l 或 wsl --list 列出所有已安装虚拟机

wsl -l -v 显示详细信息(也不怎么详细)

wsl -l -o 列出网上可用的系统

terminate

wsl -t ubuntu 关闭ubuntu

wsl --shutdown 关闭所有系统及虚拟机引擎

run

wsl -d ubuntu 启动ubuntu并进行终端

wsl -u root 以root身份支行

<distro>.exe config --default-user <username> 设置默认用户名

例如 ubuntu.exe config --default-user root

install

wsl --install 安装默认虚拟机(ubuntu)

wsl -l -o 列出网上可用的系统

执行命令

wsl <命令>

默认虚拟机

wsl 启动默认虚拟机并进入终端

wsl -s 虚拟机名 进入默认虚拟机

终端颜色

将默认用户改成root后终端没了颜色。

echo "source ~/.bashrc" >> ~/.bash_profile

vim /root/.bashrc,将39行的force_color_prompt=yes取消注释

网络连接

Accessing network applications with WSL | Microsoft Docs

虚拟机IP: ip a | grep eth0

物理机IP: cat /etc/resolv.conf,在nameserver后的是IP

GUI

使用 WSL 运行 Linux GUI 应用 | Microsoft Docs

安装输入法

https://patrickwu.space/2019/10/28/wsl-fcitx-setup/

搜狗输入法 Linux 版

卸载虚拟机

wsl --unregister <DistributionName>

修改虚拟机名称

Allow WSL distros to change their WSL name · Issue #4241 · microsoft/WSL · GitHub



    关于我
    乐趣源
    已关注 | 取消
    • 0 关注
    • 10 文章
    • 788075 访问

    文章目录
    关注他的人 (1)
    回到顶部