WSL——windows上的linux子系统

时间:2022-07-23
本文章向大家介绍WSL——windows上的linux子系统,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

引言

自从windows10软件商店提供linux子系统,再不需要像虚拟机一样繁琐的配置网络和内存等了。特别适合用来做本地linux环境学习和测试。

windows开启linux

控制面板->程序->启用或关闭windows服务->开启运行Linux的windows子系统 微软商店安装ubuntu(centos也有,但是收费)

下载ubuntu 安装好打开应用就启动一个linux黑窗口

windows的linux

子系统访问电脑目录

cd /mnt

/mnt为电脑目录挂载在子系统的共享目录,里面挂载的文件夹对应每个电脑盘

下载镜像源修改为国内

  • ubuntu
    sudo vim /etc/apt/sources.list

清空文件内容,填写下面内容(中文注释删除)

    # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

    # 预发布软件源,不建议启用
    # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

执行

    sudo apt-get update
  • centos
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    cd /etc/yum.repos.d/
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    yum makecache
    yum -y update

更多文章,请搜索公众号歪歪梯Club