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, I pre­fer Linux to Windows. Yet Windows ex­cels at en­ter­tain­ment and of­fice work. Microsoft Office re­mains the best of­fice suite I have en­coun­tered, and OneNote ranks among my fa­vorite note-tak­ing ap­pli­ca­tions. And let’s not for­get my beloved Blizzard games—Di­a­blo, Starcraft, and oth­ers.

One so­lu­tion for in­te­grat­ing both sys­tems is dual-boot. However, con­stantly switch­ing be­tween two op­er­at­ing sys­tems grows tire­some. Moreover, you must con­fig­ure both sys­tems to trans­fer files across dif­fer­ent par­ti­tion for­mats.

Another ap­proach is run­ning Windows or Linux in a vir­tual ma­chine. Since I fre­quently play video games, Windows can­not serve as the guest OS. Running Linux vir­tu­ally seemed promis­ing, but un­for­tu­nately my lap­top lacked the horse­power to run the VM smoothly.

Finally, Microsoft in­tro­duced a new fea­ture in Windows 10 called the Windows Subsystem for Linux’. Surprisingly, it works flaw­lessly—with only a few mi­nor caveats.

Settings

  1. Enable the Windows Subsystem: open Windows features and se­lect Windows Subsystem for Linux. Wait for in­stal­la­tion to com­plete and restart.

  2. Open the Microsoft Store and in­stall Ubuntu. I also no­ticed OpenSuse in the store. Hopefully more dis­tri­b­u­tions will be­come avail­able in the fu­ture—es­pe­cially Arch Linux or Manjaro, my per­sonal fa­vorites.

  3. After ex­per­i­ment­ing with Ubuntu and Tmux in cmder, I dis­cov­ered that wsltty works best for avoid­ing font ren­der­ing and ar­row key is­sues. It also runs faster than cmder, though cmder of­fers more 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 months of search­ing for a bet­ter so­lu­tion, I fi­nally dis­cov­ered ArchWSL—easy to in­stall and highly con­fig­urable. It also turned out that wsltty was­n’t quite what I needed due to lin­ger­ing Unicode font and in­put de­lay is­sues. Now I use xfce4-terminal with 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

Windows Defender proved so an­noy­ing that I had to in­ter­vene. Somehow, it con­stantly scans the Linux folder, caus­ing every­thing in the Subsystem to crawl. A bet­ter workaround: add the Linux folder to Windows Defender’s ex­clu­sion list.