The Shell
Imagine trying to write an essay by selecting words from a drop-down menu. You could eventually construct sentences, but you would be limited to the words the menu designer chose for you. This is what it is like to use a GUI: the point-and-click environment you use daily. It is intuitive, but it restricts you to pre-defined actions.
As a computational biologist, you need precision and power. You need to speak to the computer directly, without a menu getting in the way. You need the Command Line Interface (CLI). In the CLI, you type text commands, and the computer obeys. It is the difference between pointing at a picture of a meal and telling the chef exactly how you want your steak cooked.
The “black box” you type into is powered by two distinct components working in tandem. It is vital to distinguish between them:
- The Kernel: This is the core of the operating system. It controls the hardware—the CPU, memory, and hard drive. It is the “chef” in the kitchen doing the actual work.
- The Shell: This is the program that listens to you. It takes your text command, interprets it, and tells the kernel what to do. It is the “waiter” taking your order.
The Shell operates in a continuous cycle known as a REPL (Read-Evaluate-Print Loop).
- Read: The Shell waits for you to type a command and press Enter.
- Evaluate: It figures out what program you want to run.
- Print: It runs the program and displays the result on your screen.
- Loop: It displays a prompt (usually a
$) and waits for your next command.
Example
Let’s look at what actually happens when you type the common command ls (which stands for “list”):
- You type:
lsand hit Enter. - The Shell reads: It sees the text “ls”.
- The Shell interprets: It searches your computer for a program named
ls. It finds it and tells the Kernel, “Run this program.” - The Kernel executes: The hardware spins up, reads the current directory, and sends the names of your files back to the Shell.
- The Shell prints: You see a list of your files (e.g.,
lab_report.docx,data.csv). - The Shell loops: The prompt returns, ready for your next instruction.
Newcomers often confuse the Terminal with the Shell. The Terminal is the window on your screen. It accepts keyboard input and displays text. It is just a wrapper (like a television set). The Shell is the program running inside that window, processing your commands (like the broadcast showing on the TV).
Course Standards and Setup
Biology software lives on Linux. To ensure compatibility, we enforce a strict environment standard for this course.
For Windows Users
You must install the Windows Subsystem for Linux (WSL). This is not a simulator; it runs a genuine Linux kernel inside Windows.
Warning
Do not use PowerShell or Command Prompt. They use different syntax and logic. Using them here will lead to immediate errors.
Microsoft provides some helpful installation instructions. You should be able to open up PowerShell and run the following command to install WSL (while inside PowerShell).
wsl --installYou will then have to set up a new Linux username and password. From this point forward, all commands should be executed in your WSL.
Once you are logged in, you can update your WSL with the following bash command.
sudo apt update && sudo apt upgradeInstall the following applications in WSL to make your class experience smoother.
sudo apt-get install ssh git helix nano vim wget curl build-essential htop python3 python3-pipThen you should install pixi using the following command.
curl -fsSL https://pixi.sh/install.sh | shYou can still use Visual Studio Code with WSL; see here for more information.
For macOS Users
macOS is built on Unix, the cousin of Linux. You can use the default Terminal.app found in your Applications folder.
For Linux Users
You are already home. No preparation is required.
You will encounter different shells, most commonly Bash (Bourne Again Shell) and Zsh (Z Shell). For this course, they are effectively identical. If you are a beginner, stick to the default shell provided by your operating system (Bash for WSL, Zsh for modern macOS).
Learning Resources
We do not use a static textbook for this section. The Shell is a tool best learned by doing.
The Missing Semester of Your CS Education
Read the Course overview + the Shell and Shell Tools and Scripting. Focus on the concepts; you do not need to complete the exercises yet.
Software Carpentry: Introducing the Shell
Read this entire lesson to reinforce the basics of navigation and file manipulation.