The University of Western Australia
Computer Science and Software Engineering
 
 

Department of Computer Science and Software Engineering

CITS4407 Open Source Tools and Scripting

Windows10Running Linux on a Windows-10 computer

There are a number of possible ways to run a faithful set of Linux commands on a Windows computer but, for students with little Linux or systems-administration experience, the procedures can be daunting. Options include using:

  • a virtual machine, which can be noticeably slower than running a native Linux distribution (such as in the CSSE labs), or

  • modifying your system to become a dual-boot system where you install Linux on a newly-created disk partition and then select, at boot time, which operating system you wish to run (such as in the CSSE labs).

A simpler approach to the options, above, is to enable and run Microsoft's Windows Subsystem for Linux (WSL). Your computer must be running an up-to-date version of Windows-10.
WSL will not run on Windows-7.

Enabling Windows Subsystem for Linux (WSL)

  1. Instructions to enable, download, and setup WSL: How to install Windows Subsystem for Linux (WSL) on Windows 10

    Complete all Steps 1-7 of the section "How to install Windows Subsystem for Linux using Settings", and then
    complete all Steps 1-8 of the section "Installing Linux distros using Microsoft Store".

    Most students choose the Ubuntu distribution (often because that's what their friends choose).

  2. WSL is intended for running Linux command-line programs. However, it's also possible to run graphical Linux desktop programs (such as web-broswer) using an application termed an X-windows server. We'll install the open-source X-windows server named VcXsrv.

    Visit sourceforge.net/projects/vcxsrv/, download the VcXsrv Windows X Server (41MB), and run the downloaded installer (a native Windows application).

  3. The downloaded program is named Xlaunch; run it. Click next on the prompts until you reach the "Save configuration" (the other defaults are OK).

  4. We want VcXsrv to launch at Windows startup without asking about its options. Save the configuration file in the Windows folder:

     %AppData%\Microsoft\Windows\Start Menu\Programs\Startup 

    (that is one single, long, pathname),

  5. You might receive a prompt to allow X-windows traffic through your firewall. Cancel/deny this request else other computers on your network may be able to access your X-server.

  6. Finally, click on the Finish button. A new X-windows icon should appear in your system tray (near your laptop's battery indicator).

Configuring Linux within WSL

The default installations of Linux that run within WSL are quite minimal, possibly not up-to-date, and do not provide a number of helpful Linux utilities. The following steps, all executed by a Linux shell (window) while running WSL, will download and install a suitable environment.

Just cut-and-paste the following commands using your mouse. The first time you run sudo, it will ask for your Linux password.

  1. Firstly, ensure that your Linux distribution (within WSL) is up-to-date:

    shell> sudo apt-get update && sudo apt-get upgrade
    shell> sudo apt-get dist-upgrade && sudo apt-get autoremove

  2. We need to install some packages to bring provide a reasonable working environment:

    shell> sudo apt install ca-certificates findutils vim nano curl openssh-client less apt-utils git

  3. Configure your bash shell so that graphical Linux applications will automatically 'connect to' the X-windows server:

    shell> echo "export DISPLAY=localhost:0.0" >> ~/.bashrc
    shell> source ~/.bashrc

When running Linux within WSL, your Windows files with be available below the directory /mnt

A big thanks to UWA students David Adams and Ryan Oakley for testing things out and writing some instructions.

Background reading (if interested)

This Page

Written by: Chris.McDonald@uwa.edu.au