Bitpath

Lesson 1 · Unit 01

The shell, set up

How a name is found, aliases and functions, startup files, history search

13 exercisesabout 3 min

What you practise

  • PATH and how a command is found, environment variables and where they are set, aliases and functions, startup files, history search

Try a question from this lesson

Pick one

A real date program sits in /usr/bin. The first line defines a shell function with the same name. What does the second line print?

shell
date() { echo "my date"; }
date

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Where a name comes from

Bash looks for a name in this order: alias, function, builtin (part of the shell itself, like cd), then each folder on PATH, left to right. The first hit wins.

When a command surprises you, ask the shell what it found: type name, or type -t name for a one-word answer.

shell
type -t cd
type -t grep
greet() { echo hi; }
type -t greet

Concept

Startup files

Aliases and functions vanish when the shell closes, so they go in a file bash reads at startup.

A login shell (what you get over SSH) reads ~/.bash_profile. Any other interactive shell, such as a new terminal tab, reads ~/.bashrc. A script reads neither.

Keep shortcuts in the rc file and make the profile load it.

shell
# ~/.bash_profile
export PATH="$HOME/bin:$PATH"
source ~/.bashrc

10 more exercises in the app

  • 2× type the answer
  • 4× multiple choice
  • 2× fill the blanks
  • 1× true or false
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy