环境

windows10 1803

开启wsl

控制面板->程序和功能->启用或关闭windows功能
启用: 适用于linux的windows子系统

安装debian

windows.store中,下载debian;
安装后rootfs位置:

./Administrator.SC-xxx/AppData/Local/Packages/TheDebianProject.DebianGNULinux_76v4gfsz19hv4/LocalState/rootfs

如果c盘不够大的话,项目文件夹可以用符号链接到其它盘;

使用

开始菜单,输入bash, 进入debian;

换源
pc-050846:/mnt/c/Windows/System32$ sudo vi /etc/apt/sources.list

vim里执行

:s/deb.debian.org/mirrors.aliyun.com/
:wq

继续

sudo apt-get update
装上fish

sudo apt-get install fish

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  bc bzip2 file fish-common javascript-common libexpat1 libjs-jquery libmagic-mgc libmagic1 libpcre2-32-0 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libssl1.1 libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 lynx lynx-common mime-support python python-minimal python2.7 python2.7-minimal xsel xz-utils
Suggested packages:
  bzip2-doc doc-base apache2 | lighttpd | httpd python-doc python-tk python2.7-doc binutils binfmt-support
The following NEW packages will be installed:
  bc bzip2 file fish fish-common javascript-common libexpat1 libjs-jquery libmagic-mgc libmagic1 libpcre2-32-0 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libssl1.1
  libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 lynx lynx-common mime-support python python-minimal python2.7 python2.7-minimal xsel xz-utils
0 upgraded, 29 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.0 MB of archives.
After this operation, 45.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

运行 fish, 自动补全效果不错;

使用国人开发的wsl-terminal

官方主页
下载后,解压, 双击运行open-wsl.exe, 进入命令行;

经过一段时间使用,发现wsl-terminal有种种bug,异常。现在推荐1)使用Mobxterm这个ssh远程神奇。Mobxterm v11.0版以上,开始支持 wsl-ubuntu等。自带x环境, 可以直接打开gitk, meld等gui程序。 2)使用cmder这个windows下的终端神奇。 cmder非常不错,但可惜缺少xorg环境。要想打开gui,还需要另外安装xorg; 所以不如Mobxterm更佳.

看看vi版本
pc-050846:/mnt/c/Windows/System32$ vi --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 30 2017 18:21:38)
Included patches: 1-197, 322, 377-378, 550, 703, 706-707
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Small version without GUI.  Features included (+) or not (-):

看下磁盘
pc-050846:/mnt/c/Windows/System32$ mount
rootfs on / type lxfs (rw,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
none on /dev type tmpfs (rw,noatime,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,gid=5,mode=620)
none on /run type tmpfs (rw,nosuid,noexec,noatime,mode=755)
none on /run/lock type tmpfs (rw,nosuid,nodev,noexec,noatime)
none on /run/shm type tmpfs (rw,nosuid,nodev,noatime)
none on /run/user type tmpfs (rw,nosuid,nodev,noexec,noatime,mode=755)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noatime)
C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000)
E: on /mnt/e type drvfs (rw,noatime,uid=1000,gid=1000)
看下进程
pc-050846:/mnt/c/Windows/System32$ top 
top - 00:08:33 up 0 min,  0 users,  load average: 0.52, 0.58, 0.59
Tasks:   4 total,   1 running,   3 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.5 us,  3.1 sy,  0.0 ni, 93.3 id,  0.0 wa,  0.2 hi,  0.0 si,  0.0 st
KiB Mem :  7809900 total,  4021260 free,  3559288 used,   229352 buff/cache
KiB Swap:  9605860 total,  9589664 free,    16196 used.  4116880 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
    1 root      20   0    8304    136    108 S   0.0  0.0   0:00.68 init
    3 root      20   0    8304     96     56 S   0.0  0.0   0:00.00 init
    4 njs       20   0   13696   2320   2244 S   0.0  0.0   0:00.07 bash
   10 njs       20   0   16196   1956   1408 R   0.0  0.0   0:00.14 top
试下dd命令, 成功的话就可以用dd来制作启动u盘了
pc-050846:/mnt/c/Windows/System32$  echo "hello" > a.bin
pc-050846:/mnt/c/Windows/System32$  touch b.bin
pc-050846:/mnt/c/Windows/System32$  dd if=a.bin of=b.bin
pc-050846:/mnt/c/Windows/System32$  cat b.bin
hello

配置xserver

Xming

下载Xming; 地址 https://sourceforge.net/projects/xming/
直接安装运行;
在bash里export DISPLAY=:0 即可.

mobxterm

如果已下载有mobxterm; 直接运行mobxterm后即可代替Xming;

安装nodejs/yarn

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

遇到的问题

cscript.exe报错时乱码

推测原因是wsl默认是utf8编码; 但cscript.exe是gbk, 所以报错时,显示乱码

Logo

更多推荐