Skip to content

Setup

Bash Logo

On Docker (or Podman)

If you already have a workstation with docker (or podman) installed, and are comfortable using vim or nano as a text editor, you can setup and run this entire workshop inside of a container.

docker run --name bash-workshop -it bash:5.2

You will know if it worked if your prompt changes to something similar to this.

bash-5.2#

From this point forward, if you accidentally exit the container and want to reenter it, just run the following.

docker start bash-workshop \
&& docker attach bash-workshop

Once you have a prompt inside of the container, run the following.

apk add git vim nano \
&& cd "$HOME" \
&& git clone https://gitlab.com/codrcodz/bash-programming.git \
&& cd bash-programming \
&& ls README.md

Directly On Workstation

You will need to perform these setup steps from an internet-connected workstation with a Linux-based operating system.

Install Bash

You will need bash (v5.x.x, preferrably v5.2.x) installed on your workstation. This is likely already done if you have a common Linux distribution.

You can check if bash is already installed by opening up a terminal emulator and running this command:

bash --version

If bash is installed, you should see something like this:

GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Note the version number on the first line. It should be a version 5.2.x number. The patch version (after the second dot in the version number) should not matter for this workshop. If you have any other v5.x.x versions of Bash, most of the labs should still work, unless they involve exporting arrays, which is a Bash v5.2+ feature.

If bash is not installed, you should see an error message that indicates that bash is not a utility available in your path. If so, you will need to install it. Most Linux distributions package the bash utility under the "bash" package name.

Install Git

In order to pull down the source code from the repository that you will be working out of, you will also need the git utility.

You can check if git (v2.x.x) is installed by running the following command on your workstation.

git --version

If installed, this command should return something like this:

git version 2.44.0

Note the version number. It should be version 2. These lab instructions may work with other versions, but have only been tested with v2. The minor and patch version (after the first dot in the version number) should not matter for this workshop.

If git is not installed, you should see an error message that indicates that git is not a utility available in your path. If so, you will need to install it. Most Linux distributions package the git utility under the "git" package name.

Clone Git Repo

Next, you will use the git utility to retrieve the source code that you will be working with today. You can copy and paste the command below to create a directory called "bash-programming" in your current user's home directory. This directory will contain the source code you will be working with.

cd "$HOME" \
&& git clone https://gitlab.com/codrcodz/bash-programming.git \
&& cd bash-programming \
&& ls README.md

The output should look something like this:

Cloning into 'bash-programming'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
README.md

The last line in particular indicates that the "README.md" file from the source code repository is now present on your workstation. If you do not see that line, one of the earlier commands likely failed.

Select a Text Editor

If you already have a text editor installed on your workstation that you are comfortable with, just use that.

Try new editors at your own risk. This is not a vim workshop...

Let Me Out
First Time Vim Users

If you have a desktop environment (DE) installed as part of your Linux distribution, you most likely already have a graphical text editor installed.

If this is your first time using a text editor, start with the graphical one your Linux distribution ships with.

  • The KDE DE team maintains kate
  • The Gnome DE team maintains gedit
  • The XFCE DE team maintains mousepad
  • The Linux Mint distro team (maintainer of the Cinnamon DE) maintains xed
  • If you are not sure what DE your distro is using, search for "text editor" in your application menu

Graphical text editors usually do not require users to know any keyboard shortcuts. Things like saving files, exiting the editor, and other common functions can all be done with the mouse/trackpad.