Why Ubuntu on Windows?

Caution

This ar­ti­cle was writ­ten in 2017. Some in­for­ma­tion may be out­dated. Nowa­days, WSL2 is avail­able with bet­ter per­for­mance and full Linux ker­nel sup­port.

For pro­gram­ming pur­poses, I pre­fer Linux to Windows. However, Windows is re­ally good at en­ter­tain­ment and of­fice work. Besides, Microsoft Office is the best of­fice suite I have ever ex­pe­ri­enced, and OneNote is one of my fa­vorite note-tak­ing soft­ware. Not to men­tion my beloved Blizzard games such as Diablo, Starcraft and other video games.

A so­lu­tion to in­te­grate Windows and Linux in one ma­chine is to in­stall dual-boot. However, I am tired of switch­ing be­tween 2 OSs. In ad­di­tion, we have to con­fig­ure the sys­tems so that it can eas­ily trans­fer files be­tween 2 dif­fer­ent par­ti­tion for­mats.

Another workaround is to run Windows or Linux on a vir­tual ma­chine. Since I usu­ally play video games, I could not use Windows as a client. Run­ning Linux vir­tu­ally seems promis­ing. Unfortunately, my lap­top is not strong enough to run the vir­tual ma­chine smoothly.

Finally, M$ comes up with a new fea­ture in Windows 10 named Windows Subsystem for Linux’. Surprisingly, it works flaw­lessly ex­cept for sev­eral mi­nor is­sues.

Settings

  1. Turn Windows Subsystem On: find Windows features and se­lect Windows Subsystem for Linux, wait for the in­stal­la­tion and restart.

  2. Open Windows Store and in­stall Ubuntu. I also saw OpenSuse on the store. Hope­fully, there will be more dis­tros adapted in the fu­ture, es­pe­cially Arch Linux/Manjaro which is my fa­vorite.

  3. After work­ing around with Ubuntu and Tmux in cmder, I have found out that wsltty is the best tool to avoid fonts bro­ken, key ar­row is­sues. Besides, it runs faster than cmder al­though cmder has many use­ful fea­tures.

Here is the re­sult:

There are sev­eral tips:

  • Change the cur­sor to block.
  • Turn off the mouse sup­port fea­ture in vim (:set mouse=) in or­der to copy text from Windows to vim.
  • Copy from vim to Windows ap­pli­ca­tions:
    1. Install xsel/​xclip on Ubuntu.
    2. Install Xming
    3. Set export DISPLAY=:0 in the bashrc or zshrc

Installing ArchLinux on WSL

After sev­eral months wait­ing for a bet­ter so­lu­tion, fi­nally I found ArchWSL which is easy to in­stall and full of con­fig­u­ra­tion. In ad­di­tion, it turns out that wsltty is not a tool I re­ally want since there are still some is­sues with Uni­code font and de­lay. Now I am us­ing xfce4-terminal with the help from Xming.

With a few steps we are able to run xfce4-ter­mi­nal di­rectly from Windows:

  1. Set Xming to run on startup.
  2. Use the fol­low­ing com­mand in Run to ex­e­cute xfce4-terminal:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -Command "iex \"path\to\arch.exe run DISPLAY=:0 xfce4-terminal\""

Windows Defender

It is so an­noy­ing that I have to turn it off. Somehow, the pro­gram al­ways scans the Linux folder. Eventually, every­thing in Subsystem runs so slow. A bet­ter workaround is to add the Linux folder to the ex­clu­sion list of Windows Defender.