Advanced Bash Scripting

Introduction

Terminology

In this lesson, we’ll clarify the often-interchanged terms—shell, CLI, terminal, console, TTY, and POSIX—and explain what POSIX compliance means for your Unix-like environment. Having a consistent vocabulary will help you follow advanced Bash scripting techniques with confidence.

The image shows a diagram with interconnected sections labeled with concepts: Shell, CLI, TTY, Terminal, Console, and POSIX. It is titled "Terminology."

Shell

A shell is a command interpreter: it reads your commands, executes them, and displays results. Different shells offer unique features, scripting syntax, and built-in utilities. Here are some of the most common:

ShellPlatformDescription
BashLinux, macOSBourne Again Shell; default on many
ZshmacOS, LinuxZ Shell with powerful customization
KornShellUnixksh; emphasizes scripting consistency
PowerShellWindows, LinuxObject-oriented automation framework
CMDWindowsLegacy command-line interpreter

CLI

A Command Line Interface (CLI) is the text-based interface that lets you type commands directly to a shell. While most shells share fundamental capabilities, each CLI might include:

  • Unique prompts and themes
  • Built-in command history and completion
  • Custom scripting hooks

CLI tools often integrate with system components like SSH, Docker, or package managers.

Terminal

A terminal, or terminal emulator, is the application window where your CLI session runs. It renders text, handles keyboard input, and manages multiple tabs or panes.

Terminal EmulatorPlatformKey Features
GNOME TerminalLinuxProfiles, tabs, custom theming
xtermCross-OSLightweight, highly configurable
Windows TerminalWindowsTabbed interface, PowerShell

Note

You can run the same shell (e.g., Bash) in different terminal emulators just as you might browse the same website in different web browsers.

Console

Originally, a console was the physical keyboard-and-display unit directly wired into a machine via a dedicated port. Think of a video game console—hardware designed for one system. Modern usage sometimes treats “console” as synonymous with “terminal,” but the historical distinction remains.

The image shows a section labeled "Consoles" with icons of a smartphone, laptop, and game controller, alongside a pixelated ghost and a clicking cursor.

TTY

TTY stands for teletypewriter. Early terminals were electromechanical devices that functioned like remote printers. Today, Unix-like systems assign each terminal session (for example, a tab or SSH session) a pseudo-TTY number. You can inspect your current TTY with:

tty
# e.g., /dev/pts/0

POSIX and POSIX-compliance

POSIX (Portable Operating System Interface) is an IEEE standard that defines a common API and shell behavior for Unix-like systems. POSIX guarantees that scripts using standard utilities and syntax will run across compliant environments.

The image is a slide titled "Terminology" featuring a section on "Command Line Shells," with an icon of a clipboard and a checkmark. It includes a note about using shells for commands and scripts.

Warning

Not all shells are fully POSIX-compliant. If you need maximum portability, use /bin/sh or check your shell’s compliance level. Inline features like arrays or extended globbing may break on strict POSIX systems.


By distinguishing between shell, CLI, terminal, console, TTY, and POSIX, you’ll reduce confusion and build a strong foundation for advanced Bash scripting.

Watch Video

Watch video content

Previous
Shell scripting vs Bash scripting