-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up Unix For Windows
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.
-
Search Powershell and run as administrator
-
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
- 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
- Following which, we can install Ubuntu, unix based OS, on WSL
wsl install -d Ubuntu
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.
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
asksapt
to obtain the latest list of available packages from the Internet. -
sudo
performsapt update
with a super-user's level permission. This command may ask you to enter your password. (Note: super-user means administrator in Unix).
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!
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:
-
bash
shell: add in the following lineexport JSHELLEDITOR=vim
-
jshell
: Within your jshell program, run this command:/set editor vim