1.1. Meet the shell

Terminal? Command line? Shell? Bash? You may have heard different names for that window with the blinky cursor so let’s take a quick step back to understand what the shell is.

1.1.1. Command-line Interface

Your computer has an operating system, or OS, that takes care of the thousands of operations per second that your computer does so that you can browse cat pictures online without a hitch. Most operating systems have a graphical use interface, or GUI, that you can navigate with your mouse and get nice visual feedback in return. If you are brand new to programming, you may have only ever used a GUI and didn’t even realize it!

mac gui

All operating systems also come with a text-based command-line interface, or shell, to interact with the OS directly. The shell has a different name depending on your OS. On Windows it’s called Command Prompt, on MacOS it’s the Terminal, and on Linux it can vary (e.g., sh, fish, csh) but the most common is bash which comes with Ubuntu.

The purpose of every shell is to send commands directly to the operating system, but each one speaks a different language. This text works with bash for a few reasons:

  1. It is used commonly by scientists and is the default shell on many servers and clusters.

  2. Since it is now easy to get bash on Windows (see below), we don’t need a separate section for the Windows command prompt.

  3. It comes by default with the Mac Terminal, you may just need to run an extra command to set it up (see below).

Mac users: On Mac versions earlier than Catalina (< macOS 10.15), the Terminal uses bash by default. Starting with macOS Catalina (macOS 10.15), the default shell became zsh. Although the zsh language is similar to bash, not all zsh things will work in bash and vice versa. You can switch your Terminal to bash at any time via the command chsh -s /bin/bash. Make sure to open a new Terminal and you will see the below if you are using the bash shell.

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

You can switch back at any time, but we recommend sticking to bash for the remainder of this chapter.

1.1.2. Windows users

Lament not, ye weary and burdened Windows users! There are many ways to get access to a bash shell on Windows.

Note: None of these are needed for this course, but they are mentioned here for future reference.

Option

Pros

Cons

Windows Subsystem for Linux

Official Microsoft-supported method, setup is easy and free, can run any Linux OS without complicated dual-booting or slow virtual machines, full access to all of your Windows files.

Requires Windows 10.

Virtual Machine (VM)

Self-contained virtual Linux program that will run in a window and can be started, stopped or completely reset at will.

Adds overhead (can be slow) and often limited in terms of CPU power and memory usage.

Dual-boot

Full version of Linux separate but on the same machine as Windows. Full CPU power and memory use.

Requires you to reserve space for another full OS on your hard drive. Requires partitioning your hard drive (can accidentally delete all your files: advanced users only!).

Google Cloud, AWS, Azure

Accessible from anywhere, can request more resources as you need them.

High initial overhead (requires advanced / technical background to setup). Charges by resources use / by the hour which can get costly.

Of these options, I would recommend the Windows Subsystem for Linux (specifically WSL2 if you have an updated version of Windows 10. Setup intructions here). It gives a seamless shell experience while still being able to use your Windows PC and programs as usual. I would also recommend getting a shell emulator (ConEmu is a good option) and an “X-server” which allows graphical programs to run (e.g. VcXsrv).