【Windows】Windows 10 下在 Cmder 中使用Linux Bash

Posted by 西维蜀黍 on 2017-06-08, Last Modified on 2021-09-21

Install

切换到Developer Mode

Win+I打开 Setting,打开Developer Mode

安装Windows Subsystem for Linux(Beta)

依次打开Control Panel - Programs - Turn Windows features on or offWindows Subsystem for Linux(Beta)打钩。

安装完成后重启。

安装Ubuntu on Windows

打开控制台,输入bash,输入y

安装完成后:

bash使用

进入bash后,就相当于进入Linux子系统啦,后面的操作和平时使用的 Ubuntu 是一样的。

查看当前发行版

cat /etc/issue

升级软件仓库

换源

  • 备份 sources.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
  • 修改为阿里云的源(修改 sources.list):
sudo cat /etc/apt/sources.list
  • 修改 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

(也可以修改为163的源,see http://mirrors.163.com/.help/ubuntu.html

更新列表

sudo apt-get update

下载并安装更新

sudo apt-get upgrade

使用Oh My Zsh

安装zsh

sudo apt-get install zsh

安装Git

sudo apt-get install git

安装Oh My Zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

bash中使用zsh

在Cmder中使用zsh

打开cmder,输入Win+Alt+P打开Settings,在Startup中找到Command line

打开Cmder后,希望:

  • 直接进入cmd:不填
  • 直接进入bash:填%windir%\system32\bash.exe ~ -cur_console:p
  • 直接进入zsh bash:填%windir%\system32\bash.exe ~ -c zsh -cur_console:p

从bash进入电脑CDE盘

cd /mnt后,mnt目录下就相当于我的电脑

Reference