Buy Me A Coffee

Install Ubuntu 16.04 in Windows 10

Created: November 25, 2018   Last Modified: February 28, 2024   Category: linux, windows   Print this pageBack to Home

Summary

In this post, I record how to install Ubuntu 16.04 in Windows 10 using Windows Subsystem for Linux.

Enable Windows Subsystem for Linux (WSL)

Open PowerShell as Administrator and use the following command.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart Windows if asked.

Download Ubuntu 16.04 Distro

You can download the distro from https://aka.ms/wsl-ubuntu-1604. At the time of writing this post, the file I downloaded is Ubuntu.1604.2017.711.0_v1.appx.

It is also possible to download the file using PowerShell

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile Ubuntu.appx -UseBasicParsing

Installing your distro

Once I have downloaded Ubuntu.1604.2017.711.0_v1.appx, in PowerShell, I use

Rename-Item .\Ubuntu.1604.2017.711.0_v1.appx .\Ubuntu.1604.2017.711.0_v1.zip
Expand-Archive .\Ubuntu.1604.2017.711.0_v1.zip C:\Users\[your-windows-username]\Ubuntu # or pick any folder you like

Replace [your-windows-username] with your Windows username.

Next, move to C:\Users\[your-windows-username]\Ubuntu and run ubuntu.exe to initialize the new distro.

Finally, add C:\Users\[your-windows-username]\Ubuntu to the Windows environment PATH using PowerShell

$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + "C:\Users\[your-windows-username]\Ubuntu", "User")

Add username to /etc/sudoers

Suppose that your Ubuntu’s username is username, then add username ALL=(ALL:ALL) ALL to /etc/sudoers.

Set default login user

In CMD, use

ubuntu.exe config --default-user username

Change Ubuntu mirrors

One can replace the default Ubuntu mirror http://archive.ubuntu.com/ubuntu/ in /etc/apt/sources.list with others. See Official Archive Mirrors for Ubuntu.

Vanilla TexLive

Before installing Vanilla TexLive as instructed here, use

sudo update-alternatives --set fakeroot /usr/bin/fakeroot-tcp

Add Bash to the context menu

See this instruction, or simply download this ZIP archive, unzip, and double-click the Add Bash to Your Context Menu.reg file to get the context menu option. Double-click the Remove Bash From Your Context Menu.reg file to remove the option.

Re-mount C: drive

See this page for more details.

sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000,umask=22,fmask=111 # the default user that gets created when WSL is first installed has a uid=1000 and gid=1000