← HW 0 overview

Setting Up WSL

CMSC 141 • HW 0 • Windows supplement

These instructions are for Windows 11 machines. If you are on macOS or Linux you already have a Unix terminal and can skip this page.

The Windows Subsystem for Linux (WSL) lets you run a real Linux environment on Windows without a virtual machine of your own or a second operating system to boot into. Install it once and you have your own Linux workspace for this course and the many later ones that assume you can work in Linux.

Installing WSL

Open PowerShell as an administrator: search for "PowerShell" in the Start menu, right-click it, and choose Run as administrator. Then run:

wsl --install

Restart your machine when it finishes. After the reboot, open PowerShell again and install the Linux version we use in this course:

wsl --install Ubuntu-24.04

Once that completes, start WSL with:

wsl -d Ubuntu-24.04

The first launch takes a moment while files decompress and get stored on your machine. Every launch after that is nearly instant. You can also open WSL by searching the Start menu for Ubuntu 24.04.

Once the terminal is open, move to your home directory:

cd

To confirm you really are inside a Linux terminal and not plain Windows PowerShell, run:

which grep

It should print:

/usr/bin/grep

If you see that, you are inside a WSL Linux terminal. This is where you run every command related to your coursework.

Accessing your files

WSL runs a Linux system inside your Windows machine, so the two keep their files in separate places. Your Linux "Documents" is not the same folder as your Windows "Documents," which trips up a lot of people at first. To reach your Linux files from Windows, open File Explorer and look for Linux in the left sidebar. Your coursework lives there and opens like any other Windows file.

Common errors

On some newer machines, wsl --install fails with:

Please enable the Virtual Machine Platform Windows feature and ensure
virtualization is enabled in the BIOS.

Often it is enough to run this in an administrator PowerShell and restart:

bcdedit /set hypervisorlaunchtype auto

If that does not fix it, you need to turn on virtualization in your BIOS. That means restarting the computer and pressing the key that opens BIOS or system settings during startup, which differs by manufacturer. Come to office hours if you need help with this step; it is fiddly and easier with someone beside you.

What WSL actually is

WSL is not an ordinary app. It runs a lightweight virtual machine inside your computer, so it behaves like a separate Ubuntu Linux machine living in a window on your desktop. Two ideas make the rest of this course easier:

Linux organizes all of its files under a single starting point called the root, written /. Your own workspace inside WSL lives at /home/<username>/, where <username> is the Linux name you chose during setup.

Because the Linux side runs in its own virtual machine, it has its own files, but it can still see your Windows files. Windows drives appear inside Linux under /mnt/. Your Windows C: drive, for example, is at /mnt/c/.

Using VSCodium with WSL

You write your Python in VSCodium, but your code runs inside the Linux virtual machine, so VSCodium needs to open your files from inside WSL rather than from the Windows side. (Install VSCodium first if you have not; see the VSCodium page.)

Open VSCodium, then open the Extensions panel (Ctrl-Shift-X), search for WSL, and install the Open Remote - WSL extension. Once it is installed, press Ctrl-Shift-P to open the command palette, type WSL, and choose WSL: Connect to WSL.

A new VSCodium window opens, connected to your Linux environment. The first connection downloads a small server component into WSL, which takes a moment. The bottom-left corner of the window shows a green badge reading WSL: Ubuntu-24.04 when you are connected. From that window, use File → Open Folder and pick a folder under /home/<username>/ to edit your coursework in the right place.

Starting a session cleanly

Every time you sit down to work on CMSC 141, start from a clean terminal in your home directory. Running this clears the screen and drops you in your home folder:

clear; cd ~

The clear command wipes the visible terminal, and ~ is the Linux shortcut for your home directory (/home/<username>). Starting here keeps your work inside your Linux home folder instead of somewhere on the Windows side by accident.

Optional: quieting the login message

Each new WSL session prints a block of system text first, the "message of the day." If you would rather skip it and go straight to the prompt, create an empty file named .hushlogin in your home directory. The file needs no contents; its presence alone is the signal.

touch ~/.hushlogin

Optional: silencing the terminal beep

When you press Tab and there are no completions, or too many to choose from, the terminal rings a "bell" to get your attention. This is the system bell, and under WSL it makes Windows play its default error sound every time, which gets old fast.

You can turn it off for good by adding one line to a file called .inputrc in your home directory:

echo "set bell-style none" >> ~/.inputrc

The set bell-style none part tells Linux to mute the bell entirely, and >> ~/.inputrc appends that setting to the configuration file, creating the file if it does not already exist. Open a new terminal afterward for the change to take effect.