最新版的Windows已经可以安装ubuntu了,算是微软开源后的一个阶段性的成果了。
功能和windows兼容性很强(不像cygwin),软链接、文件权限都是和系统一致的。并且基本所有ubuntu的功能都可以使用,安装jekyll、docker都很顺利。同时打开系统的程序也很方便。非常赞和值得程序员去尝试!!
本文后面会逐渐增加使用过程中的一些操作,今天先更新系统安装、octopress安装、docker安装。
系统安装
直接去微软的官网下载最新版系统ISO,然后安装系统 专业版 (教育版比较干净一些,但是网上没有破解方式啊)。
Ubuntu
The Windows Subsystem for Linux lets developers run Linux environments – including most command-line tools, utilities, and applications – directly on Windows, unmodified, without the overhead of a virtual machine.
安装Ubuntu
最新版的Ubuntu已经进入到稳定版。直接打开商店,搜索Ubuntu,然后安装即可。大概200M的样子,很快就安装了。然后Launch会初始化创建用户。
相关的一些有用的文档:
安装mintty
CMD方式操作Ubuntu太难受了,mintty操作就像SecurtCRT一样,简单方便。安装 wsltty-1.8.0-install ,使用mintty来运行ubuntu。
默认mintty的配置放在 %APPDATA%\wsltty
。在子目录theme下可以 http://ciembor.github.io/4bit/ 下载一个主题放到该目录下,然后在mintty配置页面选择该主题。
系统文件
root挂载点:C:\Users\<user>\AppData\Local\lxss
or C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState
安装Jekyll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# https://superuser.com/questions/116625/recursively-change-owner-windows-7
#takeown /f "C:\path\to\folder" /r
#icacls "C:\path\to\folder" /reset /T
用powershell管理员权限 "提"权
PS E:\winsegit\octopress> takeown /F . /R
修改就旧系统的文件属性:
PS E:\winsegit\octopress> cacls *.* /T /G Everyone:F
sudo apt-get update
sudo apt-get install ruby-bundler
sudo apt-get install ruby-dev
sudo apt-get install make
sudo apt-get install gcc
bundle install
sudo gem update
sudo gem uninstall rake
sudo gem install rake -v 10.5.0
sudo apt-get install nodejs
rake preview
winse@DESKTOP-ADH7K1Q:~/winsegit/octopress$ rake preview
/usr/lib/ruby/vendor_ruby/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /mnt/c/Windows/System32 in PATH, mode 040777
Starting to watch source with Jekyll and Compass. Starting Rack on port 4000
/usr/lib/ruby/vendor_ruby/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /mnt/c/Windows/System32 in PATH, mode 040777
/usr/lib/ruby/vendor_ruby/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /mnt/c/Windows/System32 in PATH, mode 040777
/var/lib/gems/2.3.0/gems/liquid-2.6.1/lib/liquid/htmltags.rb:43: warning: key "index0" is duplicated and overwritten on line 46
[2017-10-29 22:48:09] INFO WEBrick 1.3.1
[2017-10-29 22:48:09] INFO ruby 2.3.1 (2016-04-26) [x86_64-linux-gnu]
[2017-10-29 22:48:09] INFO WEBrick::HTTPServer#start: pid=39 port=4000
Configuration file: /mnt/e/winsegit/octopress/_config.yml
Source: source
Destination: public
Generating...
done.
上面warning提示也有对应的Issue,但也没所谓暂时不理: https://github.com/Microsoft/WSL/issues/1426
安装docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
winse@DESKTOP-ADH7K1Q:~$ uname -r
4.4.0-43-Microsoft
winse@DESKTOP-ADH7K1Q:~$ uname -a
Linux DESKTOP-ADH7K1Q 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux
winse@DESKTOP-ADH7K1Q:~$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
winse@DESKTOP-ADH7K1Q:~$ lsb_release -cs
xenial
winse@DESKTOP-ADH7K1Q:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
winse@DESKTOP-ADH7K1Q:~$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
winse@DESKTOP-ADH7K1Q:~$ sudo apt-get update
winse@DESKTOP-ADH7K1Q:~$ sudo apt-get install docker-ce
winse@DESKTOP-ADH7K1Q:~$ sudo service docker start
* Starting Docker: docker [ OK ]
winse@DESKTOP-ADH7K1Q:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
winse@DESKTOP-ADH7K1Q:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
winse@DESKTOP-ADH7K1Q:~$
运行windows系统应用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
winse@DESKTOP-ADH7K1Q:~$ ln -s /mnt/e/local/usr/share/npp/notepad++.exe text
winse@DESKTOP-ADH7K1Q:~$ cp -r ../winse-cygwin/new_post.sh ./
winse@DESKTOP-ADH7K1Q:~$ cat new_post.sh
cd ~/winsegit/octopress/
rake new_post["$1"] | tail -1 | awk -F: '{print $2}' | while read line
do
name=${line#source/_posts/}
newpath=source/_stash/$name
mv $line $newpath
echo -e "\n\n--END" >>$newpath
~/text $newpath &
done
winse@DESKTOP-ADH7K1Q:~$ ./new_post.sh "windows run ubuntu"
/usr/lib/ruby/vendor_ruby/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
mkdir -p source/_posts
重新配置git
用powershell修改原来的权限后,然后用shell来进行设置。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#powershell
takeown /F . /R
cacls *.* /T /G Everyone:F
#ubuntu shell
winse@DESKTOP-ADH7K1Q:~$ cp -r ../winse-cygwin/.ssh ./
winse@DESKTOP-ADH7K1Q:~$ cd .ssh
winse@DESKTOP-ADH7K1Q:~/.ssh$ chmod 600 id_rsa authorized_keys
winse@DESKTOP-ADH7K1Q:~/.ssh$ chmod 644 id_rsa.pub config
winse@DESKTOP-ADH7K1Q:~/winsegit/octopress/_deploy$ rm -rf *
winse@DESKTOP-ADH7K1Q:~/winsegit/octopress/_deploy$ git clone git@github.com:winse/winse.github.com.git ./
winse@DESKTOP-ADH7K1Q:~/winsegit/octopress$ git config --global user.email winseliu@qq.com
winse@DESKTOP-ADH7K1Q:~/winsegit/octopress$ git config --global user.name winse
winse@DESKTOP-ADH7K1Q:~/winsegit/octopress$ rake preview
winse@DESKTOP-ADH7K1Q:~/winsegit/octopress$ sh public.git.sh
–END