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
Notes

Great for debugging unexpected command behavior.

Get resolved command path

Print how a command would be resolved.

bashANYcommandpath
bash
command -v bash
Notes

Portable pattern for existence checks in scripts.

Show builtin help

Display builtin help text.

bashANYhelpbuiltins
bash
help read
Notes

Useful for quick lookup without leaving the terminal.

Create alias

Create a shell alias.

bashANYaliasinteractive
bash
alias ll='ls -lah'
Notes

Aliases are best for interactive shells, not scripts.

List aliases

Print current aliases.

bashANYaliasinteractive
bash
alias
Notes

Good for debugging startup files.

Remove alias

Remove a shell alias.

bashANYaliasinteractive
bash
unalias ll
Notes

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
Notes

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
Notes

Useful when debugging shell behavior or startup files.

List shopt options

Print optional shell behavior toggles.

bashANYshoptoptions
bash
shopt
Notes

Bash separates many optional features under shopt.

Enable recursive globstar

Enable ** recursive globbing.

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

Very handy for script discovery and file operations.

Enable extended globbing

Enable advanced glob patterns.

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

Useful for richer filename matching.

Disable pathname expansion

Disable glob expansion.

bashANYsetglob
bash
set -f
Notes

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
Notes

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
Notes

Handy for quick corrections in interactive shells.

Show readline bindings

Inspect key bindings handled by readline.

bashANYbindreadline
bash
bind -P | head
Notes

Useful when customizing terminal shortcuts.

Reload current shell rc

Load commands from a file into current shell.

bashANYsourcestartup
bash
source ~/.bashrc
Notes

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 &
Notes

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

List jobs

List shell jobs with process IDs.

bashANYjobsbackground
bash
jobs -l
Notes

Interactive Bash tracks stopped and background jobs.

Bring job to foreground

Resume a job in foreground.

bashANYjobsforeground
bash
fg %1
Notes

Use jobs to inspect job numbers first.

Resume stopped job in background

Resume a stopped job in background.

bashANYjobsbackground
bash
bg %1
Notes

Common after Ctrl+Z.

Wait for background PID

Wait for a specific background process.

bashANYwaitbackground
bash
pid=$!
wait "$pid"
Notes

Capture $! right after starting a job.

Disown background job

Remove a job from shell job table.

bashANYdisownjobs
bash
disown %1
Notes

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
Notes

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
Notes

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
Notes

Helpful in wrappers and CI scripts.

List active traps

Print current trap handlers.

bashANYtrapdebug
bash
trap -p
Notes

Useful during debugging and library-style shell scripts.