Configuration

When you move into a new lab, the first thing you do is organize your bench. You place your pipettes on the right, your notebook on the left, and your reagents on the top shelf. You set it up so you can work without having to think.

The Shell allows you to do the same thing. It is not just a tool; it is a fully programmable environment. You can change how it looks, how it behaves, and how it understands your commands.

Dotfiles

How does the computer remember your preferences? It relies on Dotfiles. These are simple text files that sit in your home directory. They are named with a leading period (e.g., .bashrc or .zshrc).

Why the dot? The period tells the operating system to treat the file as “hidden.” It prevents your home folder from looking cluttered, keeping these configuration gears turning silently in the background.

The most critical of these are the Run Control (rc) files.

  • For Bash: ~/.bashrc
  • For Zsh: ~/.zshrc

Think of the rc file as the Shell’s “morning routine.” Every single time you open a new terminal window, the Shell wakes up, reads this file from top to bottom, and executes every command inside it before it lets you type a single word.

Caution

When you edit your .bashrc or .zshrc, the changes do not apply to your current open window (because the morning routine already happened!). You must close the terminal and open a new one, or type source ~/.bashrc to force the Shell to re-read the file.

What Do We Configure?

We typically use the rc file to control three major behaviors.

Environment Variables

These are global settings that act like the “physics” of your shell universe. They tell other programs how to behave.

  • Example: export EDITOR=nano
  • Intuition: This tells your system, “Whenever a program needs me to edit text, launch Nano (not Vim).”

Aliases

Aliases are your personal shortcuts. They allow you to map a long, complex command to a short keystroke.

  • The Problem: You find yourself typing ls -lah (list all files, hidden files, in human-readable sizes) fifty times a day.
  • The Fix: You add this line to your rc file: alias ll="ls -lah"
  • The Result: Now, you simply type ll, and the Shell expands it for you. This saves thousands of keystrokes over a semester.

The PATH

The $PATH variable is the source of the most common frustration for beginners: the dreaded Command not found error. To fix it, you must understand how the Shell finds programs.

Imagine you ask a friend to find a specific book. You hand them a list of five libraries and say, “Check these libraries in this exact order. Bring me the first copy you find.” The PATH is that list of libraries. It is an ordered list of directories where the Shell looks for programs.

Example

Let’s look at what happens when you type python and hit Enter:

The Shell checks your PATH

It sees a list like:

  1. /usr/local/bin
  2. /usr/bin
  3. /bin

The Hunt Begins

  • It looks in /usr/local/bin. Is there a file named python here? No.
  • It looks in /usr/bin. Is there a file named python here? No.
  • It looks in /bin. Is there a file named python here? Yes.

Execution

It stops searching and runs the program found in /bin.

If you install a new bioinformatics tool in a custom folder (e.g., /home/alex/my_tools) but you do not add that folder to your $PATH, the Shell will never look there. It will check the standard folders, fail to find the tool, and give up. You must append your new folder to the search list in your rc file: export PATH="$PATH:/home/alex/my_tools"

Learning Resources

Software Carpentry: Shell Scripts (Variables)

Read the section explaining variables. While this lesson focuses on scripts, the concept of assigning values to names (variables) is identical to how you configure your environment.

The Missing Semester: Shell Tools and Scripting

Read the “Shell Scripting” section up to “Shell Tools.” The explanation of aliases and dotfiles here is excellent and industry-standard.

Last updated on