Ngoc Tam Lam, PhD

Autonomy Engineer

Back

How to setup Linux subsystem in Window 10

Posted on Jan 20, 2019


The blog shows the guide to setup Linux subsystem in Window 10.

There are some steps which can help you working on Linux system

  • Changing some features in Window as the below images image - image
  • image
  • Next step is downloading the Ubuntu app from Microsoft Store in Window.

image

Working on Ubuntu bash

  • If we do $ ls command, there is nothing here.
  • $ cd / then $ ls we can see the root of subsystem. mnt is the C folder of Window
  • cd mnt - $ ls - $ cd C now we are working on C folder of window
  • From /mnt/c/users/ngoct/Projects we do $ sudo apt update to avoid data corruption if we work on the folder in linux subsystem inside window folder.
  • Next is to upgrade $ sudo apt upgrade.

Working on Visual Studio Code on WSL:Ubuntu

  • Install

    • tamlam@DESKTOP:/mnt/c/Users/ngoct/Projects/coder$ code.
    • Create a new file: $ touch main.cpp
  • Setting

    • Fix error: image image Ctrl + Shift + P in the tab of c_cpp_properties.json, change the default setting to “compilerPath”: “/usr/bin/g++”

image

  • Run the code

$ gcc main.cpp -lstdc++ -o main.o then $ ./main.o in the Terminal on VSCode

image

Reference: