IT 3110 : Advanced System Administration

The shell

Review

  • Bash
    • command interpreter, very common
  • "You will also encounter tasks that involve a sequence of actions to perform that are recurring, or very complicated, or both. Shell programming, usually referred to as shell scripting, allows you to automate these tasks for ease of use, reliability, and reproducibility."

Filename Expansion or Globbing using wildcards

  • * any string
  • ? any single char
  • [abc] any of enclosed chars match
  • Behavior of ls .* ?
  • echo f*
  • [!abc] not any of enclosed chars match

Shell Expansion

  • Include a string in single quotes unless it contains elements you want shell to interpolate
  • echo $5 fries! # try without, with double, and single quotes
  • Shell escape character with \
  • you can’t embed a single quote inside single quotes, even if using a backslash

Builtin commands

  • type, which
  • A builtin command is just that; it is built into the shell itself, while an external command is an external file launched by the shell.
    • The external file could be a binary or another shell script, why do we care?
      • builtins will always be available (for a particular shell) but external programs may or may not be installed
      • if you name your script the same name as a built-in, the built-in will always have precedence
  • Built-in commands usually can't do a (-h for help). But you can do help echo.

Interactive vs non-interactive

  • An interactive shell requires human intervention
  • Non interactive shell doesn't (init script, bootup script, cronjobs?)
  • See current shell options with echo $-, if you see an i, you are interactive.
    • (i.e. Create a script that does that command and run the script)

Bash

You can run on windows, using Ubuntu on Windowshere

Review

Review

Review

Review