Skip to main content

Appendix K Windows Subsystem for Linux

The Windows Subsystem for Linux (WSL) may be installed on computers running Windows 10. Several distributions of Linux are available. We will use Ubuntu as an example; working with other distributions is quite similar. The latest news and announcements about WSL may be found at https://msdn.microsoft.com/commandline/wsl/about.

Installing WSL.

If you have Windows 10 with OS Build greater than 16215 (August 2016), then installing WSL is not difficult. Just follow the (reasonably straightforward) instructions given by Microsoft at the address https://msdn.microsoft.com/en-us/commandline/wsl/install_guide.

Upon completion of the installation, you should

  • be able to use the bash command from the PowerShell window,

  • have your own WSL userid (distinct from Windows),

  • have your own WSL password (distinct from Windows).

Installing software.

The default configuration of WSL does not have the software needed for creating documents with PreTeXt.

The program xsltproc is used to create your readable documents. It is installed with the command sudo apt-get install xsltproc.

You are now ready to set up PreTeXt.

Putting PreTeXt on your computer.

Here are the steps necessary to get the PreTeXt software onto your computer:

  • Make a new directory mkdir mathbook

  • Make your own clone of the PreTeXt repository git clone https://github.com/rbeezer/mathbook.git

  • Move to the new directory cd mathbook

  • Initialize the new directory with git pull

This last command synchronizes your files with those in the official repository. You should run it frequently to keep your files up to date.

The simplest example.

Here is a brief description of the use of WSL to create readable files. You, as the author, create the xml file. The system will contain an appropriate xsl file that translates your xml file to something readable.

Several editors come with WSL by default including nano, pico, vi, and vim. In addition, editing is possible using notebook.exe. Here are the steps to follow:

  1. Type the command cd to align yourself in your home directory.

  2. Use one of the editors to create a file called hw.xml (you could use the command nano hw.xml), and add the following text:

                <?xml version="1.0" encoding="UTF-8" ?>
                <pretext>
                    <article xml:id="hw">
                    <p>Hello, World!</p>
                    </article>
                </pretext>
                
  3. Run the command xsltproc mathbook/xsl/pretext-html.xsl hw.xml Upon completion, your should have a file called hw.html.

  4. You now want to view the hw.html file in a browser, This is done with the command explorer.exe hw.html.

The edit-xsltproc-view cycle just given may seem daunting at first blush. Some things that can help:

  • Pressing the up arrow when at the command line displays the previously executed commands. Hitting the enter key while such a command is displayed executes it. This saves a lot of retyping.

  • It is possible to define aliases to shorten commands. Your local Linux guru can show how this is done.

  • It is possible to define scripts to shorten multiple commands. Your local Linux guru can show how this is done.