Windows10 中启用 Linux 子系统
2016 年,微软宣布了一个重磅消息,微软在 Windows 10 中增加了 Linux 子系统,称为“Bash on Ubuntu on Windows”。
想必有些同学肯定也想试试 Linux,但又离不开 Windows,我们建议可以先试试这个子系统。
根据微软官方 Bash on Ubuntu on Windows - Installation Guide 一文,我做了一些尝试。
微软官方提示,使用这一功能需要 64 位机器,系统版本要求 14393 及之后的版本。
想使用这一子系统,首先启用 Windows 子系统功能,只需两个步骤:
(1)启用 Windows 10 的 “使用开发人员功能”(左下 Cortana 处搜索“开发”)。
选择“开发人员模式”;
(2)启用“启用或关闭 Windows 功能”(左下 Cortana 处搜索“启用”);
勾选“适用于 Linux 的 Windows 子系统(Beta)”(随后重启)
重启之后,打开 cmd(Windows+R,输入 cmd)或者 Windows+X,选择“命令提示符(C)”。
输入 bash
,按照提示输入 Y
。然后静静等待即可,这时候你可以去喝杯茶或者咖啡。数分钟后,安装完成。
借助 lsb_release 查看发行版信息,lsb_release
的含义是 打印当前 LSB (Linux Standard Base) 和发行版信息
lsb_release -a
发现这个子系统实质是 Ubuntu 14.04,意味着通常可以按照 Ubuntu 的习惯操作该子系统。
更新源
首先来设置更新源,这里用阿里云的源。
nano /etc/apt/sources.list
添加以下内容:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
保存。
测试网络是否连通
ping -c5 t.cn
系统升级、更新
apt update
apt upgrade
新增用户
adduser newbie
usermod -a -G admin newbie
切换用户
su newbie
重新安装 OpenSSH Server
根据网上搜索结果,建议重新安装 OpenSSH Server
sudo apt remove openssh-server
sudo apt install openssh-server
编辑配置文件:
sudo nano /etc/ssh/sshd_config
修改一下参数,其中下列内容的最后一行为新增行。
Port 2222
PermitRootLogin no
PasswordAuthentication yes
UsePrivilegeSeparation no
AllowUsers newbie
最后,重启服务。
sudo service ssh --full-restart
(本文整理者:NULL)