Premium lesson

The Anatomy of Commands

Shell·4 min read·Jan 1, 2025

A shell command is a structured textual directive entered into a command-line interface by a user to interact with an operating system or software application.

When entered, the shell processes the command, interprets its meaning, and executes the specified operations described by the command.

In some cases, the execution of a command may result in the display of textual data in the terminal referred to as the output of the command.

Each command follows a predefined syntax and semantics, and is usually composed of distinct elements, such as the command itself, flags to modify its behavior, and arguments that provide additional context or data for the command to act upon.

The command prompt

When opening a new terminal window, the first thing you should see appearing is a sequence of characters, usually terminated by a percentage sign % or a dollar sign $, called a command prompt.

razvan:~$

It is here to indicate to you that the shell is ready to accept commands, as it literally prompts you to take action.

Beside being a shell readiness indicator, the prompt can also be customized to include colors, special characters, and other elements, such as the current directory or the username, to make it more informative or just visually pleasing.

In this lesson and the following ones, the command prompt will be represented as a single dollar sign $.

$

The command syntax

A shell command is generally composed of:

  • A command name.
  • A list of optional flags.
  • A list of optional arguments.
icon light bulb key

Unlock the CLI & Scripting with Bash module

Learn how to gain advanced control over the OS and automate complex routine tasks prone to manual errors with the CLI and Bash scripting.

You get immediate access to:

  • 34 focused lessons across the CLI and Bash
  • 4 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module