The Windows Subsystem for Linux lets developers run GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.
Before you can run Linux distros on Windows, you must enable the Windows Subsystem for Linux
optional feature and reboot.
- Open PowerShell as Administrator and run:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Restart your computer when prompted.
This reboot is required in order to ensure that WSL can initiate a trusted execution environment.
Here we take the installation of Debian GNU/Linux
as an example, and installation directory is C:\WSL\Debian
.
cd C:\WSL
- Download using PowerShell
Invoke-WebRequest -Uri https://aka.ms/wsl-debian-gnulinux -OutFile Debian.appx -UseBasicParsing
- Download using curl
curl.exe -L -o Debian.appx https://aka.ms/wsl-debian-gnulinux
- Extract and install a Linux distro
Extract the .appx package's contents, e.g. using PowerShell:
Rename-Item Debian.appx Debian.zip
Expand-Archive Debian.zip Debian
Run the distro launcher To complete installation, run the distro launcher application in the target folder, named .exe. For example: .\debian.exe
, etc.
cd C:\WSL\Debian
.\debian.exe
- Setting up a new Linux user account
Once installation is complete, you will be prompted to create a new user account (and its password).
This user account is for the normal non-admin user that you'll be logged-in as by default when launching a distro.
See User Accounts and Permissions for WSL
.\debian.exe config --default-user root
wsl
passwd root
.\debian.exe config --default-user dev
sudo apt update && sudo apt upgrade
For more details, please see:
- https://docs.microsoft.com/en-us/windows/wsl/install-win10
- https://docs.microsoft.com/en-us/windows/wsl/install-manual
Install development tools in the directory /opt
.
sudo chown -R dev:dev /opt/
https://www.oracle.com/technetwork/java/javase/downloads/index.html
mkdir /opt/Java
cd /opt/Java
# Download jdk-8u212-linux-x64.tar.gz -- Need logged in
tar -xzvf jdk-8u212-linux-x64.tar.gz
Edit /etc/profile
:
vi /etc/profile
JAVA_HOME=/opt/Java/jdk1.8.0_212
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JRE_HOME PATH CLASSPATH
source /etc/profile
java -version
mkdir /opt/Go
cd /opt/Go
wget https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz
tar -zxvf go1.12.7.linux-amd64.tar.gz
mkdir /opt/Go/gopath
cd /opt/Go/go
vi /etc/profile
GOROOT=/opt/Go/go
GOPATH=/opt/Go/gopath
PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GOROOT GOPATH PATH
source /etc/profile
go env
go version
mkdir /opt/etcd
cd /opt/etcd
wget https://mirrors.huaweicloud.com/etcd/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz
tar -zxvf etcd-v3.3.13-linux-amd64.tar.gz
cd etcd-v3.3.13-linux-amd64
./etcd
vi /etc/profile
ETCD=/opt/etcd/etcd-v3.3.13-linux-amd64
PATH=$PATH:$ETCD
export ETCD PATH
source /etc/profile