Skip to content

Setting Up Unix For Windows

danqiye1 edited this page Jan 21, 2022 · 4 revisions

Setting Up Unix Computing Environment on Windows 10 with WSL

Credits: Prof Henry Chia And Prof Ooi Wei Tsang


WSL, or Windows Subsystem for Linux, is a subsystem that allows users to run a Unix computing environment within Windows 10 and 11. This is the recommended method for having a local Unix computing environment for your Windows 10/11 machine, for the purpose of CS1010, CS2030, CS2030S, and CS2040.


Running Powershell to install Ubuntu

  1. Search Powershell and run as administrator

  2. Run the following command which helps you to enable WSL on your windows Machine

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  1. As WSL Version 2 is now available on Windows for sometime now. Either WSL 1 or 2 should be fine. Here is the setup for WSL 2
wsl --set-default-version 2
  1. Following which, we can install Ubuntu, unix based OS, on WSL
wsl install -d Ubuntu

Launching WSL

To launch WSL, you can hit ⊞ Win + R and type in wsl or bash followed by enter. This should bring up the Unix command-line interface for you to interact with the Unix computing environment.

Getting ready to install tools

Ubuntu comes with apt as the package manager, which is a convenient way to list, search, install, update, and uninstall software and libraries in WSL.

After you have set up WSL, run the following:

sudo apt update

What it does:

  • apt is a command to install, upgrade, search, and uninstall software and other packages in Ubuntu.
  • apt update asks apt to obtain the latest list of available packages from the Internet.
  • sudo performs apt update with a super-user's level permission. This command may ask you to enter your password. (Note: super-user means administrator in Unix).

Accessing your files

Note that this unix command-line interface operates on a separate filesystem as your Windows filesystem. Your home directory should be in /home/<username>/ instead of C:\Users\<username>\. In your unix home directory, do run the command explorer.exe . to open your current directory using windows explorer!

JShell Related Issues

In the event that you are unable to edit sets of code in Jshell, you will need to setup its editor to vim. As a result, please do either one of the two steps:

  1. bash shell: add in the following line export JSHELLEDITOR=vim

  2. jshell: Within your jshell program, run this command: /set editor vim