The Windows subsystem for Linux, also known as WSL is a feature added in Windows 10 allowing users to run native Linux command line tools, scripts, applications & more, directly on your Windows machine!
It's a great tool for developers who want the power of the Linux environment without having to dual boot or run a separate machine running another distribution. It's also a good way to learn some of the Linux basics and get a feel for a different programming environment.
Many of you would have heard of
bash. The native shell & scripting language that comes bundles with most Linux distributions. The good news is that Bash comes with WSL, allowing you to run command line tools, applications & more.
The first step is to fire up
powershell as an administrator and enter the following command.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
You'll be prompted to restart your machine so go ahead and do so to enable the new feature.
Installing your distribution of choice
The easiest way to get up and running with your new Linux distro is to head over to the Windows store and search for one of the following:
- SUSE Linux Enterprise Server
- Debian GNU/Linux
- Kali Linux
We'd recommend starting out with Ubuntu if this is your first time experimenting with Linux.
Go ahead and click
get to download and instal your new distro.
Launching the Bash shell
From the start menu or using cortana to search for you distro name, click to launch the application and wait for the shell to spawn. You should see a new shell window with a message saying something along the lines of
installing, this may take a few minutes.... Just sit tight and wait for it to do its thing.
Setting up your Unix account
Once installed, you'll be prompted to create a new UNIX user, just go ahead and following the instructions in the terminal by entering your username and creating a password.
Updating your distro & packages
It's best practice to update your distro and system packages after installation and periodically throughout time. Go ahead and run the following command to update
sudo apt update && sudo apt upgrade
If you're prompted to enter your password go ahead and do so.
Congratulations! You're ready to start exploring the Windows subsystem for Linux!
Do not try to change, edit, access or modify Linux files or directories using Windows applications or tools as you may corrupt them or do damage to your WSL installation. The Linux directories and files are hidden by default to prevent this and I highly advise you follow this advice!
Instead, consider creating a new directory on your windows machine and navigating to it using the WSL Bash terminal. Use this directory to create sub directories & files that you'll be able to access & modify in both Windows and WSL.
Quick tip - Create an alias in your
.bashrcfile to quickly navigate to your new WSL directory on your windows machine at the touch of a command
We've got a full guide on setting up your WSl development environment so go ahead and read it to get up to speed on creating your new WSL workflow (It's really simple)
Be sure to drop a comment below if you have any feedback!