Setting Up Unix For Windows - nus-cs2030/2122-s1 GitHub Wiki
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. This is the recommended method for having a local Unix computing environment for your Windows 10 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 unstable at the moment, we will default to the usage of WSL Version 1 using the following command:
wsl --set-default-version 1- Following which, we can using the web to invoke a request to
download the necessary
appxfile to download the package forwsl-ubuntu
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile C:\Ubuntu.appx -UseBasicParsing- Once the installation is complete, run the following command to install this package
Add-AppxPackage C:\Ubuntu.appxTo launch WSL, you can hit ⊞ Win + R and type in Ubuntu followed by enter. This should bring up the Unix command-line interface for you to interact with the Unix computing environment.
if there's an error "Windows cannot find 'Ubuntu'", you can try running WSL by hitting ⊞ Win + R and typing in wsl followed by enter. You will be in the user home directory, navigate to other directories with the cd command. eg. cd Desktop/CS2030/
View other directories with the ls command.
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 updateWhat it does:
-
aptis a command to install, upgrade, search, and uninstall software and other packages in Ubuntu. -
apt updateasksaptto obtain the latest list of available packages from the Internet. -
sudoperformsapt updatewith a super-user's level permission. This command may ask you to enter your password. (Note: super-user means administrator in Unix).
In your current 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:
-
bashshell: add in the following lineexport JSHELLEDITOR=vim -
jshell: Within your jshell program, run this command:/set editor vim