setp1. 先开启wsl功能
- 打开控制面板——“程序”——“启用或关闭Windows功能”——勾选“适用于Linux的Windows子系统”——“确定”。完成,已经成功启动WSL功能。最后重启电脑
setp2. windows appstore搜索ubuntu, 点击下载安装
setp3. 修改Ubuntu的apt-get源为国内镜像源
-
原文件备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak -
编辑源列表文件
sudo vim /etc/apt/sources.list
-
将原来的列表删除,添加如下内容(中科大镜像源)
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
setp4. 添加ubuntu目录
- 打开cmd,输入\wsl$, 点击Ubantu文件夹,右键,点击映射网络驱动器就可以添加到我的电脑里了,注意只有启动Ubantu之后才可以打开该磁盘
Note: 过程中需要重启ubuntu系统:
- 右键win,选择window powershell管理员,运行net stop LxssManager关闭Ubuntu系统,然后start系统
问题
- 1 命令行输入 sudo vncserver -geometry 1600x900 :1,出现以下错误:
Warning: LAPTOP-993I9DKB:1 is taken because of /tmp/.X1-lock
Remove this file if there is no X server LAPTOP-993I9DKB:1
A VNC server is already running as :1
- 输入:sudo vncserver -kill :1
出现:
输入 sudo vncserver, 提示:Can't find file /home/givenchy/.vnc/LAPTOP-993I9DKB:0.pid You'll have to kill the Xvnc4 process manually
Warning: LAPTOP-993I9DKB:1 is taken because of /tmp/.X1-lock
Remove this file if there is no X server LAPTOP-993I9DKB:1
Warning: LAPTOP-993I9DKB:2 is taken because of /tmp/.X2-lock
Remove this file if there is no X server LAPTOP-993I9DKB:2
Warning: LAPTOP-993I9DKB:3 is taken because of /tmp/.X3-lock
Remove this file if there is no X server LAPTOP-993I9DKB:3
Warning: LAPTOP-993I9DKB:4 is taken because of /tmp/.X4-lock
Remove this file if there is no X server LAPTOP-993I9DKB:4
如图,说明前四个端口已经被占用:
按照提示,删除tmp目录下的相关缓存文件,又提示如下错误:
索性删除/tmp下面的所有文件:sudo rm /tmp/.X11-unix/*,之后便可以重新利用之前的端口号了。
原因:占用端口号之后,未及时关闭(kill)
reference
https://www.tkdcz.top/post/46.html