Installation of tools: WSL2/Linux etc.

  • We need to set up command line terminal. It will be used extensively throughout the course.

  • All of command line terminal options are either Linux or Linux-like (technically the OSX one is based on Free BSD but that doesn’t make any practical difference here).

  • If you already have a Linux computer, there’s nothing to do but it is highly recommended to read through the material as it provides perspective to other operating systems.

  • Note that operating systems are continuously updated and you should always check the latest information regarding the current version of yours.

Installation of basic tools

  1. Set up command line terminal either by installing full Linux, WSL/WSL2 in Windows or Linux in a virtual machine. A decision needs to be made and we discuss these options below.

  2. Learn the basics of command line and the main differences between Linux, Windows and/or Mac.

  3. In this course we Python and Jupyter Lab/Notebook:

    • They have pre-requisites and we need to install them first. This includes software such as a C/C+±compiler, Xcode for OSX users, cmake, and so on.

    • After the prerequisites have been installed, we install Python and Jupyter.

The figure shows a summary of the options depending on your current OS. For Windows users the recommended choice is WSL2 (WSL2 has some advantages over WSL, but WSL works as well). Dual boot Windows 10/Linux is a good choice but requires more work and care. Virtual machine is a safe choice but requires a lot of memory.

Mac users already have a command line terminal. It can be found in

Finder -> Applications -> Utilities -> Terminal

That same location has also XQuartz that will be needed to run GUI based applications.

Linux vs others

Fig. 1 The three main operating systems and the main options.

If you are happy with the recommended choices, the move on the next section and installation. If you want more information, just click the dropdown below to read more.

Important

When you install any software the responsibility is entirely yours. It is imperative to back up your data and essential files. Doing that ensures that in the case something goes wrong, you will be able to recover your previous work and software. While it is rare that something goes wrong, it can and does happen, and one should take the necessary precautions. And always remember to do virus checks.

Recovering a crippled computer may be very hard or impossible.

Additional information

The dropdowns provide more information for those interested and are not required reading.

Time to start the installations. The time each step takes depends on your operating system.

Task 1: Terminal, WSL/WSL2, Xcode and such

Based on your current operating system: Choose one of the tab options that is the most suitable for you. What we are going to do is the following independent of the operating system.

Update your system if necessary. Go to the next step.

WSL/WSL2 is needed for command line terminal. It gives Linux distribution without GUI. It is possible to also use GUI with some extra software as will be indicated. This also works on Windows 11.

Here is the procedure:

  • First: Check the Detailed up-to-date instructions from Microsoft

    • Note: If you are not in the Windows Insiders program (if you don’t know what it is, then you aren’t), you must follow the Manual Installation steps

    • The installation took about 20 minutes on an old 1.3 GHz laptop.

    • Requires the use of PowerShell as Administrator. Pay attention when the instruction ask you to open the PowerShell as an Administrator`.

  • For Ubuntu distribution, choose 20.04 LTS. Here’s what to choose at the Microsoft App Store: Ubuntu 20.04 LTS at MS App Store

  • After installation, you must update WSL/WSL2

Here are the detailed steps for WSL2 (if in doubt, see the video below):

  • Open PowerShell as an Administrator. In PowerShell, give the command

    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    

    Reboot your computer

    Reboot computer
    
  • After rebooting, download the WSL2 package: WSL kernel update

  • Next: Give the command:

    Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
    
  • After this, give the command:

    wsl --set-default-version 2
    
  • If all went fine, open Microsoft App Store and search for Ubuntu. Select, Ubuntu 20.04 LTS and get it.

  • Once you have it, click Launch.

    Launch
    
  • The procedure will ask you to create a user account. This a user account for your Linux shell. You can choose any username you want.

  • Once done, you must run update to get the latest updates for your syste,. This is done with the Ubuntu package manager by giving the command

    sudo apt update
    
  • After the process finishes, run the upgrade procedure by giving the command

    sudo apt upgrade
    

This will take some time. But once it finishes, you have a new WSL2 system installed and you’re good to proceed.

  • IMPORTANT: The home directory is different from you Windows home. WSL2 can see you Windows directories but not the other way around. Your Windows directories are located at

    /mnt/c
    

You will need this later.

  • Optional: Do you also want GUI with WSL2? You can install any of the following for that (not shown on the video):

    • VcxSrv. Free.

      • WSL2 requires some extra settings: 1) When staring XLaunch, in Extra Settings select also Disable access control. You also need to give the commands:

        export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
        export LIBGL_ALWAYS_INDIRECT=1
        

        Open an X-application and see that it works. If it does, then put the two above lines at the end of your .bashrc. These instructions are from Stackoverflow. The setting have been tested and they work.

    • Xming. Free.

    • X410 from Microsoft App Store.

      • This is not free but works well. When using with WSL2, X410 needs to be give permission to get through the firewall. See Using X410 with WSL2

You can also watch the following video of WSL2 installation on laptop:

The video follows the manual installation steps (=non Windows Insiders Program ones)

  • Check which version of MacOS you have (under About this Mac).

    • if you have Catalina: It is not advisable to update it to Big Sur as there are reports that some of the tools that we need may not work. This may, of course, change / have changed (Nov 2020). The installations have been tested on Catalina but not Big Sur.

Check if you have Xcode. If not install it, it is required. Xcode requires registration but it is free. It provides the necessary compilers and other tools.

  • Xcode. Follow the instructions as Apple’s web site.

    • Xcode provides the compilers, libraries and other development tools

    • This may take some time depending on your internet connection.

Task 2: Package manager

You already have a package manager, so there is nothing to do.

When WSL/WSL2 was installed, you got a package manager. There is nothing to do at this step.

The next task is to install a package manager such as MacPorts or Homebrew. Here, we use Homebrew but MacPorts works well too. However, the instructions on these pages are for Homebrew only.

See the installation and operating instructions at the Homebrew web site. Here is a copy from the web site.

Installation:

  • Open a terminal window and give the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once done, update Homebrew:

brew update

Now you are ready install software using Homebrew. For how to do it and further instructions, see Homebrew web site.

Optional: Create work directory for the course

Independent of your operating system:

  • Open a terminal window and type

    cd
    

This changes the directory to your home directory (we will go through Linux commands separately, right now we just want to create a work directory for the course material).

  • Then, give the command

    mkdir SciComp9502B  
    

This directory can be used for course related data, scrips and programs.

  • Check that the directory is there by giving the command

    ls -lt