Skip to content
IT glossary
DevOps and cloudUpdated December 3, 2026

Bash

Bash is a shell: a program that runs commands you type in a terminal or save in a script. It can connect programs together to automate tasks such as building software or processing logs.

Also known as: shell, командная строка

What Bash is

Bash stands for Bourne Again Shell. It is a command interpreter commonly found on Linux. The terminal is the interface where you type and see output; Bash is the program that decides what your command means. You can use the same terminal with a different shell, such as Zsh.

An interactive Bash session reads commands as you enter them. A Bash script stores commands in a file so they can run without someone typing each step. Scripts can also make decisions, loop over files, and group reusable steps into functions.

What happens when you run a command

Bash handles syntax such as quotes, variable references, filename patterns, and redirections before running a command. Some commands are built into the shell. For example, cd changes Bash's own working directory. Other commands, such as wc, normally run as separate programs.

A pipe (|) connects one command's standard output to the next command's standard input. A redirection such as > report.txt sends standard output to a file instead, replacing its contents; >> appends. Output is separate from exit status: a program can print nothing and succeed, or print useful information and still report failure. By convention, status 0 means success. The specific meaning of a nonzero status depends on the program.

Example: find a setting in a file

#!/usr/bin/env bash

config=${1:-app.conf}
if grep -q '^DEBUG=true$' < "$config"; then
  printf '%s\n' 'Debug mode is enabled.'
else
  status=$?
  if [[ $status -eq 1 && -r $config ]]; then
    printf '%s\n' 'Debug mode is not enabled.'
  else
    printf 'Could not check %s\n' "$config" >&2
    exit 2
  fi
fi

Run it with bash check-debug.sh 'local app.conf'. The quotes keep the path intact, and < feeds the file to grep. The -q flag suppresses matching output: the if tests the exit status, not text printed by the command. Status 1 from grep means no line matched; a failure to open the file also makes the condition fail, so the script checks readability before treating status 1 as a negative result.

Where Bash fits

Bash is useful for wiring together tools in build jobs, deployment scripts, and routine Linux maintenance. It's less convenient when the job involves complex data structures or extensive error handling. For example, a shell script can call a tool that understands JSON rather than trying to parse JSON itself.

Don't assume every shell supports Bash syntax. Running bash script.sh explicitly selects Bash, while sh script.sh selects whatever implementation provides sh on that system. When you execute a script directly as ./script.sh, its #! line selects the interpreter, provided the file is executable.

What interviewers look for

A typical interview task is to explain why build | tee build.log can appear to succeed when build fails. By default, the pipeline reports the status of tee, its last command. With set -o pipefail, the status is that of the rightmost command that failed, or zero if all succeeded. Interviewers also look for correct quoting and an explanation of which failures a script should handle explicitly.