Skip to content

01 introduction_notes

Carsten Fortmann-Grote edited this page Mar 17, 2024 · 5 revisions

1 Introduction to the Shell

Setup

  • Download shell-lesson-data.zip and move the file to your Desktop.
  • Unzip/extract the file. Let your instructor know if you need help with this step. You should end up with a new folder called shell-lesson-data on your Desktop.

Question:

  • What is a command shell and why would I use one?

Objectives:

  • Explain how the shell relates to the keyboard, the screen, the operating

system, and users’ programs.

  • Explain when and why command-line interfaces should be used instead of

graphical interfaces.

Rule #1: Don’t panic!

Imagine the following task:

  • copy line 1521 from all files in 200 directories into a new file
  • estimate how much time this would take you with a GUI word processor
  • We will see that the shell accomplishes this task in seconds

The shell is good at

  • repetitive tasks
  • do stuff on a remote computer (e.g. compute cluster)
  • combine tools into pipelines
  • automate tasks
  • keep work reproducible
  • Reduces risk for repetitive strain injury

The shell is not good at

  • doing stuff that needs visual interaction
  • visualization (although there are ways…)
  • start from scratch (you gotta know the basics)

Getting started

  • open your shell
  • Windows: Start->git bash
  • Mac: Terminal
  • Linux: |CTRL-ALT-T| or |ALT-F2| “gnome-terminal”

The prompt

  • “>” or “$” or combinations of these plus hostname, username, current directory, …
  • do not type the prompt when entering commands

Our first shell command: ls

enter

$ ls |Enter|
  • what happens?

enter

$ ks |Enter|
  • what happens?

Take home

  • A shell is a program whose primary purpose is to read commands and run other programs.
  • This lesson uses Bash, the default shell in many implementations of Unix.
  • Programs can be run in Bash by entering commands at the command-line prompt.
  • The shell’s main advantages are its high action-to-keystroke ratio, its support for automating repetitive tasks, and its capacity to access networked machines.
  • A significant challenge when using the shell can be knowing what commands need to be run and how to run them.