In this guide I will walk you through setting up the Linux Subsystem for Windows 10, changing your Linux system to use the same home directory as your Windows system, and setting up your shiny new Bash terminal to use it for development.
We need to check your version of Windows
Open Powershell and run
systeminfo | Select-String "^OS Name","^OS Version"
Follow these directions
- Open Powershell as Administrator
- Run
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Run
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
. This will probably have you reboot your computer. - Open cmd.exe and run
bash
to install Linux
Based on these directions
- Open Ubuntu
- Enter the command
sudo nano /etc/passwd
Find your account's line, which might look like:beth:x:1000:1000:,,,:/home/beth:/bin/bash
- Open your file explorer, navigate to
C:\Users\
and find what your home directory is called. This is usually similar to the username you use to log into Windows. For example, mine is "mrsbe" - Change the home directory that we found in vim, which above is
/home/beth
, to the new directory, using WSL notation. It should look likeYOUR_LINUX_USERNAME:x:1000:1000:,,,:/mnt/c/Users/YOUR_HOME_DIRECTORY:/bin/bash
- Save the file
- Exit Ubuntu and re-launch it
- To test, use the commands:
cd ~
andpwd
- Open Ubuntu
- Run
sudo apt-get update
- Close Ubuntu and restart it
Run the following block of code to add all the basic packages you use in your code. This will take a while, so get comfy
sudo apt -qq install git
sudo apt -qq install nodejs
sudo apt -qq install npm
sudo apt -qq install python-pip
sudo npm install -g create-react-app nodemon live-server
Now run the next block of code to be able to use the 'open' command.
echo "open() {" >> ~/.bashrc
echo "last=\${1: -1}" >> ~/.bashrc
echo "if [ \$last = / ]" >> ~/.bashrc
echo "then" >> ~/.bashrc
echo "file=\${1::-1}" >> ~/.bashrc
echo "else" >> ~/.bashrc
echo "file=\$1" >> ~/.bashrc
echo "fi" >> ~/.bashrc
echo "cmd.exe /C start \"\${file}\"" >> ~/.bashrc
echo "}" >> ~/.bashrc
This part is super easy. Open VSCode, hit CTRL + SHIFT + P
. For the "terminal.integrated.shell.windows" key, set the value to "bash.exe"