一、设置开发人员选项
1、window开始选项中,点击【设置】按钮
2、选择【安全和更新】
3、选择【开发者选项】
4、选择【开发人员模式】
二、修改系统设置
打开控制面板------>程序与功能---->启用或关闭windows功能------>勾选 [适用于linux的windows子系统] 选项
三、去应用商店安装Ubuntu
1、打开Microsoft Store,搜索wsl
2、选择Ubuntu
3、安装Ubuntu
四、安装好了之后,在开始栏中,双击打开Ubuntu,并设置新的账号和密码
五、将/etc/apt/source.list文件备份并更改Ubuntu软件源为国内源:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list
1、打开文件后,按 【i 】键进入编辑模式,然后将以前默认的软件源注释掉,添加新的国内软件源进去,如图:
2、添加完之后,按【esc】键,然后输入【:wq】,最后按【enter】键即可。
3、国内几个主要的Ubuntu软件源如下,任选其一即可:
(1)、阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
(2)、网易源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
(3)、中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
(4)、清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
(5)、浙大源
deb http://mirrors.zju.edu.cn/ubuntu/ bionic main multiverse restricted universe
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-security main multiverse restricted universe
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic main multiverse restricted universe
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-security main multiverse restricted universe
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe
备注:关于国内各种源的来源 https://blog.csdn.net/qq_34889607/article/details/82500602?utm_source=blogxgwz0 ,任意选择其中之一即可。
六、执行相关命令
1、执行sudo apt-get update进行更新
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
2、安装基础软件环境xorg
sudo apt-get install xorg
3、安装桌面环境xfce4(中途需要输入y确认)
sudo apt-get install xfce4
4、安装远程桌面服务xrdp(中途需要输入y确认)
sudo apt-get install xrdp
5、配置xrdp端口
sudo sed -i 's/port=3389/port=3390/g' /etc/xrdp/xrdp.ini
这里面3389是默认配置,这里将其改为3390是避免和windows的端口冲突。我们折腾的是子系统不是虚拟机,两边的端口号是通的。比如在wsl中开一个8080端口的WebServer,在windows中开浏览器是可以直接访问的
6、配置xsession
sudo echo xfce4-session >~/.xsession
这一步其实是在告诉系统,开启桌面环境的时候开启什么桌面环境。
7、启动xrdp
sudo service xrdp restart
或者
sudo /etc/init.d/xrdp restart
启动成功后会看到如下提示
* Starting Remote Desktop Protocol server
[20190514-19:06:59] [DEBUG] Testing if xrdp can listen on 0.0.0.0 port 3390.
[20190514-19:06:59] [DEBUG] Closed socket 6 (AF_INET6 :: port 3390)[ OK ]
8、汉化
sudo dpkg-reconfigure locales
然后一直按键盘上的↓
找到zh_CN UTF-8
,然后按空格勾选,再tab
切换到ok
上回车,接下来的界面选zh
再回车。
9、安装中文字体
sudo apt-get install ttf-wqy-microhei
首次进入中文界面会提示是否重命名那几个文件夹,建议保持英文状态,因为有些路径是写进配置文件了的,重命名会带来不必要的麻烦。
桌面环境汉化之后就是中文输入法了,这个需要用浏览器访问搜狗网页,所以先装下chrome吧(自带的火狐一开始打不开,几天后又能用了)。
9、安装chrome
sudo apt install google-chrome
安装完成后在命令行输入 【sudo google-chrome --no-sandbox】
启动。如过有问题请查看此处