Pcornel
Linux · Shell & Bash

Aliases

Cheat sheet · https://pcornel.dk/topic.php?topic=2689

Back to the Topic

Answer

An alias replaces the first word of an interactive command with other text, e.g. alias ll='ls -l'. Aliases are defined in ~/.bashrc and do not work in scripts by default.

Remember

Aliases (rm='rm -i') can hide the real command; run \rm or command rm to bypass. Scripts do not expand aliases — use functions there.

First checks

  • bash -x script.sh — trace each expanded command
  • bash -n script.sh — syntax check only
  • shellcheck script.sh — common bugs and quoting problems
  • echo $? — exit code of the last command

Verify in this order

interactive command line → first word checked against aliases → replaced → expanded and run

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2689

Confirmation

Confirm action

Continue?