5. Shell basicsΒΆ

ShellΒΆ

Please read and understand the following questions:

  • What’s a shell?

  • What operations can you do with a shell?

  • What shells are there available?

  • How do you access the shell?

  • What’s a CLI, respectively a CLI tool?

  • How’s a developer using the shell?

  • How’s an engineer using the shell?

Important

Take 30 minutes to research and answer the questions, then discuss them with your coach.

TerminalΒΆ

Find the Terminal on your Mac and open it. Let’s see if you can run the first command:

echo "Hello $USER"

This should output your username on the Terminal.

Hint

Alternatively you can also download iTerm 2 for a better & more advanced terminal.

Bash scriptingΒΆ

If you could output your username with the command above, read & start this Bash Scripting Tutorial for Beginners.

You need to understand the following concepts:

  • Relative and absolute paths (e.g. /usr/local/bin/example, bin/example, ../bin)

  • Displaying the current directory (i.e. pwd)

  • Changing the directory (i.e. cd)

  • Listing files and directories (i.e. ls)

  • Getting the content of a file (e.g. cat, more)

  • Permissions (i.e. users, groups, permission modes chown, chgrp, chmod)

  • Create output (i.e. echo, printf)

  • Redirect output (i.e. >)

  • Variables (e.g. $FOO_BAR, ${FOO_BAR})

  • The UNIX shebang (i.e. #!… in the first line)

  • Exit codes (e.g. what means 0 and non-0, $?)

  • Executing commands & execute bash scripts

Hint

We’re focusing on command line editors later on, especially vi(m). Do everything in your installed editor instead.