Marie-Hélène Burle

This section explains what Bash is, why it is useful to know how to use it, and how we are going to run it in this course.

Unix shells

Unix shells are command line interpreters for Unix-like operating systems1: the user enters commands as text—interactively in a terminal or in scripts—and the shell passes them to the operating system.

1 Unix-like systems include Linux, macOS, and a few others.

It is thus a way to give instructions to the machine through text instead of using a graphical user interface (GUI).

Types of Unix shells

Bash (Bourne Again SHell)—released in 1989—is part of the GNU Project and is the default Unix shell on many systems (although macOS recently changed its default to Zsh).

Prior to Bash, the default was the Bourne shell (sh).

A new and popular shell (backward compatible with Bash) is Zsh (zsh). It extends Bash’s capabilities.

Another shell in the same family is the KornShell (ksh).

Bash is the most common shell and the one which makes the most sense to learn as a first Unix shell. It is also the one used by default on the Alliance clusters.

Why use a shell?

While automating GUI operations is really difficult, it is easy to rerun a script (a file with a number of commands). Unix shells thus allow the creation of reproducible workflows and the automation of repetitive tasks.

Imagine you had 1000 files in a directory and you wanted to rename them all.

Using Windows Explorer or MacOS Finder, you could right click on every file one by one to rename it, but it would take you hours. Using Bash, this is done by a very simple command and takes an instant.

Shells are powerful to launch tools, modify files, search text, or combine commands.

Because shells are powerful, you can easily make consequential mistakes (e.g. deleting a lot of files). For this reason, it is a good idea to make backups of your data (it is a very good idea to make frequent backups of your data anyway!).

Shells also allow to work on remote machines and HPC clusters.

Running Bash

Since Bash is a Unix shell, you need a Unix or Unix-like operating system. This means that people on Linux or MacOS can use Bash directly on their machine.

For Windows users, there are various options:

How we will use Bash today

Today, we will connect to a remote HPC cluster (supercomputer) via SSH (secure shell). HPC systems always run Linux.

Those on Linux or MacOS can alternatively use Bash directly on their machine.

On MacOS, the default is now Zsh (you can see that by launching the application called “Terminal” and typing echo $SHELL followed by the <enter> key), but Zsh is fully compatible with Bash commands, so it is totally fine to use it instead. If you really want to use Bash, simply launch it by typing in “Terminal”: bash, then pressing the <enter> key.

Connecting to a remote HPC system via SSH

Step one: usernames and password

We will give you a link to an etherpad during the workshop. Add your name next to a free username to claim it.

We will also give you the password for our training cluster. When prompted, enter it.

Note that you will not see any character as you type the password: this is called blind typing and is a Linux safety feature. Type slowly and make sure not to make typos. It can be unsettling at first not to get any feed-back while typing.

Step two: logging in

 •  Linux and MacOS users

Linux users:   open the terminal emulator of your choice.
MacOS users:   open “Terminal”.

Then type:

ssh userxx@hostname
  • Replace userxx by your username (e.g. user09)
  • Replace hostname by the hostname we will give you the day of the workshop.

 •  Windows users

We suggest using the free version of MobaXterm. MobaXterm comes with a terminal emulator and a GUI interface for SSH sessions.

Open MobaXterm, click on “Session”, then “SSH”, and fill in the Remote host name and your username.

Here is a live demo.