EECS 298: Social Consequences of Computing

Windows Command line tools (WSL)

The Windows Subsystem for Linux (WSL) runs an Ubuntu Linux guest virtual machine on your Windows host machine.

When you see $ in this tutorial, you should type into your shell the command that comes after the $.

Upgrade Windows

We recommend Windows 11. Windows 10 version 2004 build 19041 and higher will also work. Here’s how to check your Windows version.

Free Windows upgrades are available for UM students via OnTheHub. If you have an older Windows machine and are not able to upgrade, please reach out to course instructors for assistance.

Install Windows Subsystem for Linux (WSL)

Start PowerShell and run it as administrator. Search for PowerShell in the start menu, then right-click and select “Run as administrator”. (Note: these instructions are based on the instructions from Microsoft.)

Check if WSL was already installed. If you see this, WSL is already installed.

C:\WINDOWS\system32> wsl -l -v
  NAME      STATE       VERSION
* Ubuntu    Stopped     2

If you see the WSL help text, WSL is not installed.

C:\WINDOWS\system32> wsl -l -v
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: wsl.exe [Argument]
...

Install WSL.

C:\WINDOWS\system32> wsl --install

Pitfall: Make sure Windows Update is enabled and your machine is up-to-date. Settings > Update and Security > Windows Update.

Pitfall: If you still get an error from wsl --install, try the Manual installation steps.

For the Linux distribution, choose the latest version of Ubuntu LTS. At the time of this writing, that’s Ubuntu 22.04 LTS.

Restart your computer.

Start PowerShell as administrator, and check that the VERSION is 2.

C:\WINDOWS\system32> wsl -l -v
  NAME      STATE       VERSION
* Ubuntu    Stopped     2

If the VERSION is 1, you must upgrade to WSL 2.

Open terminal

Start an Ubuntu Bash shell.

Install CLI tools

Use the apt package manager to install a few command line programs. Linux users will run this same command.

$ sudo apt update
$ sudo apt install wget git ssh gdb python3 tree

Use CLI tools

Now would be a great time to take a look at our CLI Tutorial.

Pro-tips

Copy paste

Copy: ctrl + shift + c

Paste: ctrl + shift + v

If Copy/Paste doesn’t work, read on to enable it.

Enable copy paste

These instructions show how to enable WSL Copy/Paste on Windows 11 H2 or newer.

Right click on the window pane header of your Ubuntu WSL terminal. Click on the Settings option in the drop down menu.

Pitfall: If your dropdown contains the option “Properties” follow the instructions for Older versions of windows.

Click on the Actions tab on the left side of the settings window.

Confirm that the “Copy text” and “Paste text” bindings exist. You may need to scroll down. Add them if needed using the “Add new” button.

Enable copy paste on older Windows

These instructions show how to enable WSL Copy/Paste on version of Windows older than 11 H2.

Click on the properties option in the dropdown.

Enable “Use Ctrl+Shift+C/V Copy/Paste” option in the Console “Options” properties page

Accessing Windows files

Windows files are accessible from Linux at /mnt/c/. You have a separate Ubuntu home directory, e.g., /home/awdeorio/.

$ cd /mnt/c/Users/awdeorio/Desktop    # Windows Desktop
$ cd /mnt/c/Users/awdeorio/Documents  # Windows Documents

CLI open file

Opens a file or directory with the default application, like a double click. See the wslview command in the CLI tutorial.

Acknowledgments

Original document written by Andrew DeOrio awdeorio@umich.edu.

This document is licensed under a Creative Commons Attribution-NonCommercial 4.0 License. You’re free to copy and share this document, but not to sell it. You may not share source code provided with this document.