Installation of tools: WSL2/Linux etc.#

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

  • All the command line terminal options are either Linux or Linux-like (technically the MacOS 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 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 use 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 MacOS users, cmake, and so on.

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

The figure below 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. Update 2023: WSL works well with GPUs.#

If you are happy with the recommended choices, then move on to 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 happen and it 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.

Pre-installation considerations

What is your operating system and what you need to do (if anything):

The listing below should help to choose what to do. Main requirements and limitations are listed.

  • If you have pure Linux or dual boot: You are good to go, no need to do anything at this time (just check that your system is up-to-date).

  • If you have Mac: MAcOS is based on Free BSD (Unix) and it has a command line terminal. Nothing needs to be done regarding getting a terminal. Optionally, you can install Linux in a virtual machine, but we are not covering that here.

  • If you have Windows: There are different options to choose from:

    • The recommended choice for Windows users is to install WSL2. From here on, WSL just referes to the latest version of WSL (there used to be a choice between WSL and WSL2 but that has been obsoleted). This provides you with a Linux installation and full command line tools.

      • Important: to Install WSL, you must have Windows 10/11. Compatibility requirements for Windows 10 (WIndows 11 just works): Version 2004 (May 2020), version 1909 (Nov. 2019) and version 1903 (May 2019). Check your Windows version but if you have kept your Windows 10 installation up-to-date, it is highly likely that you have one of above versions. WSL2 is the recommended option.

      • Installation of WSL is straightforward and is supported by Microsoft. WSL gives a CLI and also a GUI. In practise you will have Windows and Linux on your system at the same time – a great advantage. You have access to both the Windows and Linux side from both of the operating systems.

    • Dual boot is another option. In that case you will have both Linux and Windows installed and you select at the boot time which one you want to use. This works independent of which version of Windows you have, but you must have enough free space on your hard drive.

      • If you have enough disk space, this is a very clean and efficient option (although WSL offers the best of both worlds).

      • I strongly recommend not to do this if you have Microsoft Surface. While not impossible, there are reports that the process is not necessarily straightforward.

      • This is more risky than the very straightforward WSL installation.

    • The third option is to install Linux in a virtual machine inside your Windows. This works with all recent versions of Windows.

      • This requires that the computer has enough RAM. In practise, one should have at least 16 Gb since the RAM has to be divided between Windows and Linux.

      • Linux inside a virtual machine is full Linux with GUI as well as CLI.

      • We will not cover the installation here but it is straightforward albeit more time consuming that WSL/WSL2.

GPU computing:

Many popular software packages such as Tensorflow for machine learning and Gromacs, NAMD and Amber for molecular simulations can use GPUs for simulations. GPUs provide a significant speedup compared to running the simulations on CPUs. Depending on your computer, you may be able to use GPUs. If not, don’t worry, all the simulations have been tested with an older CPU-only laptop to ensure that the simulations will complete within reasonable time.

  • Linux: If you have NVIDIA GPUs, you will be able to use them for the simulations provided you install / have installed the CUDA drivers. If you have AMD GPUs, things are different. The concerns are the same as for MacOS below.

  • WSL: NVIDIA GPUs work.

  • MacOS (Intel-based): Apple uses AMD GPUs. They are not compatible with NVIDIAs CUDA but use OpenCL instead.

  • Virtual machine: No access to the GPU(s).

Warning

The responsibility is yours. When you install any software the responsibility is entirely yours. It is important to you 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 happens and one should take the necessary precautions. Recovering a crippled computer may be very hard or impossible.

Try Linux without installing

If you are curious about installing Linux either as a dual boot or as the only operating system, you can try it first using Live USB without installing.**

This allows you try it out and see if it works on your computer. This is important since this way you can see if Wifi and other devices work properly and also to check if you like the user interface. Here are the basic steps (the suggestions below are for Ubuntu and Ubuntu-based for ease):

  • To make a Live USB you need a USB pen. At least 4GB is recommended (and often needed). If you want to try several distributions/flavors at the same time, just have 2 or more pens ready. Note that the USB pen needs to be erased (and formatted) in the process so make sure that you copy all the important files to another USB/SD/HD/SSD.

  • Browse the web pages of the different flavors/distributions and see which one pleases you visually. Functionally, they all contain the same features.

    Suggestions:

    • Ubuntu Desktop default

      • Note: Pick Ubuntu 20.04 LTS (20.04.01 LTS at the time of writing this), NOT any of the newer ones.

    • The official Ubuntu flavours.

      • Simply take a look at their respective pages (at Ubuntu) and see what pleases you visually.

    • Elementary OS 5.1 Hera or the latest (winter 2022) Elementary OS 6.1 Jólnir.

      • Uses Ubuntu/Debian package management.

      • Beautiful user interface design

    • Linux Mint 20 Ulyana:

      • Uses Ubuntu/Debian package management.

      • Beautiful design

  • Once you have made your choice, download the one(s) you want. The files that you download are so-called ISO images. It is a standard archive format that we use to create a bootable USB. Note that the ISO images can be large, anything between 1 and 4 GB, or even a bit larger.

  • Create a bootable USB. The links below contain step-by-step instructions and work for all of the above Linux flavours/versions.

  • Now you can try it out. Simply insert the USB and reboot your computer.

    • Potential problems:

      • The computer boots back to Windows (or Mac). This means that USB is not recognized as a boot device. This is easy to change:

        • Solution: Reboot the computer and enter Bios. How this is done depends on bit on your computer. When you reboot, many computers usually show (for a few seconds) what are the keys to press to enter the Bios. This depends on your computer, but here are a few examples:

          • The most common keys to hold down while booting are F2, F10 and F12.

          • Lenovo: F2

          • Not here? Then you have to search the web. It is good to know this since if there ever is a serious problem with your Windows, you may need this to be able to recover your computer and OS.

          • Once in Bios, go into the boot menu and change the order of bootable devices such that USB comes first. Save and reboot. Now (provided the USB is inserted), the computer should boot to Linux.

  • Now you should be running Linux from the USB. Try it out, connect the Wifi, open software from the menus and see that everything works as expected. If everything is fine and you like the visual features, then all is good. Now you can quit or install but remember to back up your data.

  • If you want to try another distribution/flavour, just repeat the steps.

I want to try/install Linux but which version?

Which version/distribution of Linux should I install?

There are a lot of great Linux distributions to choose from.

Recommendation regarding distribution: The instructions in this document are for Ubuntu-based distributions to keep things simple. If you have not used Linux before, then the easiest way is use one of the Ubuntu based ones. There are many other excellent distributions (like Suse, Redhat, and others) and you can typically try them without installing by simply making a Live USB (see the other dropdown).

Recommendation regarding Ubuntu version: It is strongly recommended to install an LTS (Long Term Support) version. At this time (winter 2022), the latest LTS version is 20.04 LTS. The instructions below have been tested with this particular version (as well as to some degree using 18.04 LTS). Why LTS and not the absolute latest? Ubuntu releases come in 6 month cycles (April and October), but the LTS versions are released every two years. Importantly, the LTS versions are supported and maintained for five years. In other words it is a stable solution without the need to upgrade.

Recommendation regarding Ubuntu flavor: There are a lot of excellent choices and ultimately it depends what you like / what seems visually the most appealing to you.

Which distribution/version/flavor you use? Right now, our student office computers run the default Ubuntu, my 2007 iMac runs Ubuntu flavor Xubuntu and my laptop runs KDE Neon. All of the computers run LTS versions of Ubuntu (mostly 18.04 LTS and 20.04 LTS). I have used Linux since 1993 and tried many distributions including Slackware, Redhat/Fedora, SuSe, Gentoo, Arc, Elementary OS and so on - although the above talks about Ubuntu, the other distributions are equally good choices.

More information:

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

Task 1: Terminal, WSL, 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.

See the instructions at Install Linux on Windows with WSL

  • 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 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 MOLDY  
    

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

  • Check that the directory is there by giving the command

    ls -lt