bash
回车, 提示访问一个网址(https://aka.ms/wslstore), 使用浏览器访问, 重定向到应用商店, 然后可以获取需要的 Linux 子系统, 比如 DebianWindows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Windows Store:
https://aka.ms/wslstore
Press any key to continue...
uninstall using:
lxrun /uninstall /full
reboot
then:
lxrun /install /y
reboot
This gets you back to the initial installation: at least I can get at root now.
cmd -> 输入 bash
or debian
使用 Pin Start
点击 Windows 按钮, 直接输入 store
即可
In Windows admin command prompt (Super+X, A) change the default user to root:
lxrun /setdefaultuser root
Now Bash on Ubuntu on Windows logs you in as root without asking password
Use passwd
command in Bash to change the user password:
passwd your_username
Change the default user back to your normal user in Windows command prompt
lxrun /setdefaultuser your_username
In the Command Prompt or PowerShell window (not a Bash shell window):
wslconfig /setdefault <DistributionName>
正如上面所说, 如果执行 wslconfig /setdefault ubuntu
, 那么执行 bash 命令则会运行 ubuntu
wslconfig /unregister <DistributionName>
当系统出现问题, 我们可以卸载后重新安装。如: wslconfig /unregeister ubuntu
wslconfig /list
Windows 磁盘在 Linux 子系统下都是有挂载的, 输入 mount
命令可以查看挂载情况, 只要你的操作系统是中文路径就支持中文, 直接可以使用 cd 命令来切换中文目录, 非常神奇。
一般情况下 C 盘、D 盘、E 盘的挂载路径分别是 /mnt/c
、/mnt/d
、/mnt/e
, 依此类推。
Open Settings: Click the Start
button, then click Settings
.
Open Apps Category and find Ubuntu: Click on Apps button, and then search for Ubuntu (or your distribution name) under Apps & features
.
Open Advance Options: Under search results, click on Ubuntu
(or your distribution name) and then click on Advance options
.
Hit Reset: Click the Reset
button.
Since Windows 10 version 1803, closing all WSL terminal windows won’t kill background processes by default, unless the file /var/run/reboot-required is present. This file will be automatically created by apt on Ubuntu when an update requires a reboot, but if you want to manually reboot the subsystem, you can create the file yourself:
sudo touch /var/run/reboot-required
I haven’t tested this on other distributions available in the Microsoft Store. An alternative solution is to kill all processes yourself:
sudo killall -r '.*'
As an Administrator restart the windows Service “LxssManager” on Windows 10. This does a clean boot of the WSL. The services in the Linux Subsystem - for example xrdp - must be restarted if not enabled for autostart.
早期版本:
%localappdata%\Lxss\rootfs
现在, 如果安装的是 Debian:
C:\Users\Administrator\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs
$ sudo nano /etc/sudoers
## User privilege specification
root ALL=(ALL:ALL) ALL
user ALL=(ALL:ALL) NOPASSWD:ALL // 添加这行
## Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
user ALL=(ALL:ALL) NOPASSWD:ALL // 添加这行, 为什么这里也要添加? 因为如果没有添加此行, 上面的 %sudo 会覆盖 NOPASSWD:ALL 导致设置失败。
查看当前用户所在组命令:
$ groups user
user : user adm cdrom sudo dip plugdev
由于众所周知的原因, 如果直接使用这样的 Linux 子系统安装软件的话, 网速非常慢, 需要改成国内的镜像源, 我们这里使用中科大的镜像源。
由于镜像源要支持 https 协议需要安装软件 apt-transport-https(WSL 版本默认未安装), 所以我们先用 http 协议安装 apt-transport-https。
$ sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
$ sudo sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
$ sudo apt update
$ sudo apt install apt-transport-https -y
$ sudo nano /etc/apt/sources.list 加上 s 就可以了
参考文章: https://baijiahao.baidu.com/s?id=1596652006568524478&wfr=spider&for=pc
各桌面性能评价:
桌面环境 / 窗口管理器 | RAM used | % CPU used | 类型 |
---|---|---|---|
KDE 4.6 | 363 MB | 4 % | 桌面环境 |
*** Unity | 271 MB | 14% | 桌面环境(shell) |
*** GNOME 3 | 193 MB | 10% | 桌面环境 |
GNOME 2.x | 191 MB | 1 % | 桌面环境 |
XFCE 4.8 | 144 MB | 10 % | 桌面环境 |
LXDE | 85 MB | 10 % | 桌面环境 |
Debian 9 Stretch Minimal CD 用的是 XFCE, 通过打开终端点击 Help
-> About
可以看到用的是什么桌面系统。
X-Windows is a Unix/Linux Client-Server system. Although usually on the same computer, the Client and Server can be on different computers, unlike Microsoft Windows.
X11 is a network protocol. It encodes things such as graphic primitives, images, pointer motion, and key presses.
X clients are graphical applications like Firefox.
Xorg is an X server. It implements X11 and provides an interface to keyboards, mice, and video cards.
Gnome, KDE, LXDE, and Xfce are desktop environments. They provide libraries and specifications that applications use
When running X-Windows, instead of a console login, the Display Manager i.e. Lightdm starts up. The DM starts the X-server and asks for login credentials and then launches the user’s desktop environment.
Which one is faster?
Obviously LXDE. It is even lighter than XFCE. LXDE uses about 110 mb of ram when idle while XFCE is a little more bloated, taking about 200 mb (based on my experience)
Which is easier to use?
XFCE. It have more GUIs while LXDE requires you to modify configuration files in your own in some cases.
More configurable?
Both are configurable, but it depends on how much you want to play with it. It is less configurable than KDE or GNOME, though.
Can I install them?
Via the software center everything is easier. But I recommend you use lubuntu-desktop for LXDE or xubntu-desktop for XFCE. (Since they’ve prepared most of the stuff for you)
Windows Linux 子系统并不是一个完善的系统, 在使用过程中我遇到了一些问题
For the record, I had this problem when cloned a repo using git from the Ubuntu shell in Windows 10.
After I cloned the repo to a different location usin git from a Windows shell, the problem went away and the solution builds fine.
The issue was that the build scripts were looking for ‘stdafx.cpp’ in a folder with uppercase name (C:\GIT\LIBRARYX\SRC\
) and this path did not work if the solution was cloned using git from Ubuntu bash.
原因找到了, 是 Windows 驱动器挂载引起的不兼容导致的, 目前比较靠谱的做法是先 git clone
到 Linux 子系统的存储区, 然后再压缩成 .tar.gz
包, 将这个包移动到 Windows 驱动器 (挂载在 /mnt
下) 中, 然后在 Windows 下用 Windows 压缩软件解压缩。