Coder Social home page Coder Social logo

linux-subsystem-guide's Introduction

Welcome to the Linux Subsystem!

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.

Preparing Your Computer

We need to check your version of Windows Open Powershell and run
systeminfo | Select-String "^OS Name","^OS Version"

OS Version 16215 and newer

Follow these directions

Older OS Versions

  1. Open Powershell as Administrator
  2. Run Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  3. Run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux. This will probably have you reboot your computer.
  4. Open cmd.exe and run bash to install Linux

Based on these directions

Changing Your Home Directory

  1. Open Ubuntu
  2. Enter the command sudo nano /etc/passwd
    Find your account's line, which might look like: beth:x:1000:1000:,,,:/home/beth:/bin/bash
  3. 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"

  4. Change the home directory that we found in vim, which above is /home/beth, to the new directory, using WSL notation. It should look like YOUR_LINUX_USERNAME:x:1000:1000:,,,:/mnt/c/Users/YOUR_HOME_DIRECTORY:/bin/bash
  5. Save the file
  6. Exit Ubuntu and re-launch it
  7. To test, use the commands: cd ~ and pwd

Updating Bash

  1. Open Ubuntu
  2. Run sudo apt-get update
  3. Close Ubuntu and restart it

Setting up Dev Tools

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

Setting your VSCode integrated terminal

This part is super easy. Open VSCode, hit CTRL + SHIFT + P. For the "terminal.integrated.shell.windows" key, set the value to "bash.exe"

linux-subsystem-guide's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.