Introduction

Author

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.

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

They also allow to work on remote machines and HPC systems.

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 system 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 typing echo $SHELL in Terminal), 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.

Connecting to a remote HPC system via SSH

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.

Linux and MacOS users

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

Then type:

ssh userxxx@hostname
  • Replace userxxx by your username (e.g. user009)
  • 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.