Updated 2019-06-17

Windows Subsystem for Linux (WSL)

What is WSL?

  • The Windows Subsystem for Linux is a feature in Windows 10 that allows you to run in a Linux environment directly on Windows, unmodified, without the overhead of a virtual machine.
  • In addition to being able to use Linux command-line tools and apps, you can access your Windows files from within Linux, allowing for seamless data flow between the two environments.
  • WSL provides a native Bash environment for tools like SSH, git, Python, and many more

Installing WSL

  • Before installing any Linux distributions for WSL, the "Windows Subsytem for Linux" optional feature must be enabled.
  • Open PowerShell as Administrator (if prompted, allow the PowerShell app to make changes to your device)
  • Run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux.
  • Once complete, type y and then hit Enter to restart your computer.

Screenshot

  • Once your computer reboots, open the Microsoft store and search for "Linux". You will see a header that says "C:\> Linux on Windows? Totally." Click on "Get the apps" and you will be taken to the page found in the screenshot below. Several distributions are available, but for this tutorial we will describe how to proceed with Ubuntu.
  • Click the distribution of your choice, and install it by pressing "Get".

Screenshot

  • To initialize your new distribution, simply open the app from the Start menu. The first time it is run, you'll be asked to wait a couple minutes while the files are de-compressed and stored on your PC for use.
    • All future launches should be much faster.
  • You will be prompted to create a new UNIX username and password - they do not need to match your Windows credentials, but can if you would like.

Note

When you enter your UNIX password, no characters will be displayed on the screen. You will be prompted to re-enter your password to verify it before proceeding, in case you made a mistake.

  • One of the first tasks is to update and upgrade your distribution's packages.
  • On Ubuntu, type sudo apt update && sudo apt upgrade.

Note

Any time you try to run a command using sudo, you will be prompted to provide your password - this is your UNIX account password, so be sure to remember it.

  • Install any software you may find useful using apt.
    • For example, to install gcc, Emacs 25, and pip for Python 3, type sudo apt install gcc emacs25 python3-pip.
    • Type y and hit Enter to confirm that you wish to allocate the disk space and install the new packages.
  • You now can run native Linux applications from your Windows desktop!
  • If you need to access your windows file system, it is located in /mnt/c/. You can manipulate files here as needed.

Configuring WSL for GUI Applications

  • To display any type of graphical interface (plots, GUI controls, etc) on WSL, an X server will need to be installed.

  • VcXsrv is a good open source option - download, install, and run the application, using the default options.

Tip

  • To configure VcXsrv to run at startup:
    • Locate the VcXsrv shortcut in the Start Menu
    • Right click → select more → select open file location
    • Copy the VcXsrv shortcut file
    • Paste the shortcut in %appdata%\Microsoft\Windows\Start Menu\Programs\Startup
  • Export the display to the newly installed X server on Windows by typing and executing echo "export DISPLAY=localhost:0" >> ~/.bashrc in the Linux command line.

  • To have the configuration changes take effect, restart the Linux distribution or run source ~/.bashrc.

Warning

You will need to make sure your X server application is running on Windows before you start Linux for graphical applications.

Connecting to PACE clusters from within WSL

  • To SSH into the cluster, you MUST be on campus wifi or connected to the GaTech VPN.
  • From within your Linux distribution, type the following:
ssh someuser3@login-s.pace.gatech.edu
# User your GT username in place of "someuser3"
# press <return> to run
# Must be on GT campus internet or connected to GaTech VPN

Tip

If you want to run a GUI session (display plots from matplotlib for example), make sure to include the -X directive when you SSH into the head node

Perl Locale Warning

  • You may encounter a repeated warning that looks like this when running the pace-whoami command: Screenshot

  • This will not prevent you from accessing the normal functionality of the cluster, but you may find it an inconvencience. You can try the following to prevent the error when logging on next time:

    • Run logout to exit the cluster.
    • Open the /etc/ssh/ssh_config file with a text editor using sudo: sudo nano /etc/ssh/ssh_config

    Warning

    Be very careful when editing files that require sudo access. You should open a second shell at this point to ensure that if something goes wrong when you restart the first shell, you still have an unchanged shell to undo your changes.

    • Input your UNIX password to recieve edit access to the file.
    • In the file, you will see a line that says SendEnv LANG LC_*.
    • Comment out this line by adding a # to the front of it so that it now looks like

    # SendEnv LANG LC_*

    • Hit Ctrl + s to save the file and Ctrl + x to exit the text editor.
    • Restart the shell for the changes to take effect.
    • Next time you login to the pace cluster, you won't see the warning.