WSL常用操作记录
常用操作
导出
1 | wsl --export centos7 centos7.tar |
导入
1 | wsl --import centos7 C:\centos7 centos7.tar |
启动指定发行版
1 | wsl -d centos7 |
指定用户启动
1 | wsl -d ubuntu -u root |
开机自启
win+r 输入 shell:startup
写一个wsl_start.bat
内容如下
1 | wsl -d Ubuntu -u root /etc/init.d/ssh start |
sudo vim /etc/wsl.conf
1 | [boot] |
修改默认用户为root
1 | %localappdata%\Microsoft\WindowsApps\ubuntu.exe config --default-user root |
根据你的发行版决定
sudo vim /etc/wsl.conf
1 | [user] |
安装想要的发行版
这里以centos为例
首先需要docker环境,执行
1 | docker run --name centos7 centos:centos7 |
然后将容器导出
1 | docker export centos7 > centos7.tar |
然后在windows上导入
1 | wsl --import centos7 C:\centos7 centos7.tar |
启动发行版
1 | wsl -d centos7 |
卸载发行版
1 | wsl --unregister centos7 |
互相访问
wsl 里运行windows 程序
1 | # 运行windows里的python |
windows里运行wsl程序
1 | wsl -d ubuntu sudo bash -c "apt update" |
wsl里访问windows路径
1 | cd /mnt/c/Users/iuxt/Desktop |
windows 里访问wsl文件
\wsl$\Ubuntu\home\iuxt
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 杂烩饭!
评论