Skip to content

Bash on Ubuntu on Windows, the Linux subsystem on Windows

Bash on Ubuntu on Windows, or called it “Windows Subsystem for Linux (WSL)”, as the name suggests, it is the Linux subsystem on Windows.

Sometimes when we developing the software, we often has many problem we only can find tools in Linux to solve the problem. Many useful tools can’t be used for Windows.

But the Windows developer just only to install a virtual machine, or install Linux in our computer?

Of course not! native Windows environment can support Linux system —— it’s a tool named “Bash on Ubuntu on Windows”.

And I am about to start introducing it.


Installation

How do you do: Select the Developer check box

The Developer tab isn’t displayed by default, but you can add it to the ribbon.

  1. On the File tab, go to Options Customize Ribbon.
  2. Under Customize the Ribbon and under Main Tabs, select the Developer check box.
  3. Select the check box of WSL
The last check box.

And then, the system will automatically install.

After rebooting, open cmd and key in:

bash

Enter UNIX account, password, “Bash on Ubuntu on Windows” will be installed.

If you watch any error message like this:

適用於 Linux 的 Windows 子系統沒有任何已安裝的發行版本。
您可以透過瀏覽 Microsoft Store 來安裝各種發行版本:
https://aka.ms/wslstore

Maybe you can use Microsoft Store and search “ubuntu subsystem”.

I suggest you install Ubuntu 16.04 LTS. because you maybe install desktop GUI later. If you insist on choosing 18.04, you can use command to upgrade.

Installed and execute:

Enter your account and password, you’re be done.


Test Ubuntu system

We have to get a little test, first.

Execute ubuntu bash and key in:

vim test.sh

Using tool “vim” (a famous editor in Linux) to write some shell instructions。

Press “a” and enter “Insert” mode.

for i in $(seq 1 10)
do
    echo $i
done



Press “Esc” and exit the “Insert” mode, key “:wq” and save the shell.

Turn back to terminal, and use the following command:

sh test.sh

Outout

1
2
3
4
5
6
7
8
9
10

Congratulations, the system is running!


Graphical Interface

If you still want a graphical interface (but I’m not recommend), you can download a software “vcXsrv Windows X Server”.

You can install it from here: https://sourceforge.net/projects/vcxsrv/

Double click to execute the file:

Select Next
Select Install

You can see the following screen:

Select “One large window” and “Display number” choose 0, and next.
Default.
Next.
Finished.

Get back to Ubuntu Bash, use following commands to install the package we need.

sudo apt-get update
sudo apt-get install ubuntu-desktop
sudo apt-get install unity
sudo apt-get install compizconfig-settings-manager

The file is so large and needs to wait

Use “compiz” to change config.

export DISPLAY=localhost:0
sudo ccsm

Select “Ubuntu Unity Plugin” and agree all settings it need. And close this window.

Let the settings take effect:

sudo compiz

You can see the following screen.


【Remove

Removing Bash on Ubuntu on Windows is very easy. We just only to open cmd and use the command “wslconfig”.

But this command is existed after 2019, if your version is before 2019, you have to use these command to uninstall:

lxrun /uninstall /y

if you don’t have lxrun command, you have to use wslconfig.

wslconfig /l

Check the WSL version you installed.

For example, my version is “Legacy”, I have to use these command to uninstall.

wslconfig /u Legacy

And you’re done.

Leave a Reply