Bash Builtins, Job Control, and Shell Behavior

Core Bash builtins, shell options, history, aliases, job control, traps, and interactive-shell behavior.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Core Builtins

Frequently used builtins and shell introspection commands.

Inspect command resolution

Show whether a name resolves to an alias, builtin, function, or executable.

bashANYtypebuiltins
bash
type -a ls

Great for debugging unexpected command behavior.

Get resolved command path

Print how a command would be resolved.

bashANYcommandpath
bash
command -v bash

Portable pattern for existence checks in scripts.

Show builtin help

Display builtin help text.

bashANYhelpbuiltins
bash
help read

Useful for quick lookup without leaving the terminal.

Create alias

Create a shell alias.

bashANYaliasinteractive
bash
alias ll='ls -lah'

Aliases are best for interactive shells, not scripts.

List aliases

Print current aliases.

bashANYaliasinteractive
bash
alias

Good for debugging startup files.

Remove alias

Remove a shell alias.

bashANYaliasinteractive
bash
unalias ll

Use unalias -a to remove all aliases in current shell.

Disable builtin temporarily

Disable a builtin so external command resolution can win.

bashANYenablebuiltins
bash
enable -n test

Advanced tool mostly used for compatibility and testing.

set and shopt

Modify shell behavior and optional features.

List set options

Print current shell option settings.

bashANYsetoptions
bash
set -o

Useful when debugging shell behavior or startup files.

List shopt options

Print optional shell behavior toggles.

bashANYshoptoptions
bash
shopt

Bash separates many optional features under shopt.

Enable recursive globstar

Enable ** recursive globbing.

bashANYshoptglobstar
bash
shopt -s globstar
printf '%s
' **/*.sh

Very handy for script discovery and file operations.

Enable extended globbing

Enable advanced glob patterns.

bashANYshoptextglob
bash
shopt -s extglob
printf '%s
' !(*.md)

Useful for richer filename matching.

Disable pathname expansion

Disable glob expansion.

bashANYsetglob
bash
set -f

Useful when handling user-provided patterns literally.

History and Interactive Features

Use history builtins and interactive helpers.

Show history

Display recent command history.

bashANYhistoryinteractive
bash
history | tail

Interactive Bash maintains a history list and file.

History substitution with fc

Re-run last command after simple substitution.

bashANYhistoryfc
bash
fc -s old=new

Handy for quick corrections in interactive shells.

Show readline bindings

Inspect key bindings handled by readline.

bashANYbindreadline
bash
bind -P | head

Useful when customizing terminal shortcuts.

Reload current shell rc

Load commands from a file into current shell.

bashANYsourcestartup
bash
source ~/.bashrc

Often used after editing aliases, exports, or functions.

Job Control

Background jobs, foreground jobs, and waits.

Run process in background

Start a job in background.

bashANYjobsbackground
bash
sleep 60 &

The shell prints a job number and PID in interactive mode.

List jobs

List shell jobs with process IDs.

bashANYjobsbackground
bash
jobs -l

Interactive Bash tracks stopped and background jobs.

Bring job to foreground

Resume a job in foreground.

bashANYjobsforeground
bash
fg %1

Use jobs to inspect job numbers first.

Resume stopped job in background

Resume a stopped job in background.

bashANYjobsbackground
bash
bg %1

Common after Ctrl+Z.

Wait for background PID

Wait for a specific background process.

bashANYwaitbackground
bash
pid=$!
wait "$pid"

Capture $! right after starting a job.

Disown background job

Remove a job from shell job table.

bashANYdisownjobs
bash
disown %1

Useful when you want a job to survive shell exit semantics.

Send signal to job

Signal a shell job using jobspec.

bashANYkilljobs
bash
kill -TERM %1

Job specs are very handy in interactive Bash.

Signals and Traps

Handle signals and cleanup behavior.

Handle SIGINT

Run shell code when Ctrl+C triggers SIGINT.

bashANYtrapsignals
bash
trap 'echo interrupted' INT

Useful for cleanup and user-friendly interruption.

Capture exit status in trap

Inspect final exit status on shell exit.

bashANYtrapexit
bash
trap 'status=$?; echo "exiting with $status"' EXIT

Helpful in wrappers and CI scripts.

List active traps

Print current trap handlers.

bashANYtrapdebug
bash
trap -p

Useful during debugging and library-style shell scripts.