Windows10运行Ubuntu (WSL)

缘起

就是无事干想体验一下Windows上直接运行Linux的感觉,这样以后下载各种包啥的,就不用连远程的服务器了。

安装

  1. 先进入控制面板->程序->程序和功能->启用或关闭Windows功能 打开 适用于Linux的Windows子系统 选项,打勾确定。
    在这里插入图片描述
  2. 去应用商店下载Ubuntu,下载你需要的版本,这块我是安装的Ubuntu16.0.4。
    在这里插入图片描述
  3. 下载完毕后启动Ubuntu,第一次登陆需要设置用户名和密码。
    在这里插入图片描述

配置

  1. 使用sudo su切换到root用户
  2. 更换镜像源为阿里云镜像源,参考我之前的博客:传送门
  3. 配置ssh
# 卸载自带的ssh
sudo apt-get remove openssh-server
# 安装openssh-server
sudo apt-get install openssh-server
# 修改ssh_config配置文件
vi /etc/ssh/ssh_config
# 修改内容个如下
Port为2222
PasswordAuthentication yes
# 修改sshd_config配置文件
vi /etc/ssh/sshd_config
# 修改内容如下
Port 2222
UsePrivilegeSeparation no
PasswordAuthentication yes
# 重启服务
service ssh --full-restart

使用xftp工具连接测试
在这里插入图片描述
如果连接成功,那么大功告成,可以嗨皮的玩耍了!

配置代理

参考博文:ubuntu wsl 子系统使用win10 系统ss代理步骤

  1. 安装python pip

    apt install python3-pip
    
  2. 升级pip

    pip3 install --upgrade pip
    

    pip升级后Import Error:cannot import name main解决方案:传送门

  3. 安装genpac工具

    pip3 install genpac
    
  4. 生成配置

    genpac --proxy="SOCKS5 127.0.0.1:1080" -o autoproxy.pac --gfwlist-url="https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt"
    
  5. 编辑 /etc/profile 在文件最后添加(具体端口配置和ss 客户端保持一致)

    export http_proxy=http://127.0.0.1:1080
    export https_proxy=http://127.0.0.1:1080
    export ftp_proxy=http://127.0.0.1:1080
    
  6. 编辑~/.bashrc文件

    vi ~/.bashrc
    

    插入如下内容:

    source  /etc/profile
    

    使用命令source ~/.bashrc使上面的配置成功。

访问本机目录

“/mnt”目录下有“c”、“d”、“e”等文件夹,分别表示本地的C盘、D盘、E盘,直接cd到相应路径下即可。


参考资源:WSL(Windows Subsystem for Linux)的安装与使用

发布了96 篇原创文章 · 获赞 95 · 访问量 39万+

猜你喜欢

转载自blog.csdn.net/yh0503/article/details/92100943