Use it for interactive shortcuts, or when a command behaves unexpectedly because an alias changes it.
Aliases
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.
1. type <cmd> — is it an alias?
2. alias — list all.
3. Bypass with \cmd or command cmd.
4. Remove with unalias <name>; edit ~/.bashrc to persist.
5. Need it in scripts → write a function.
interactive command line → first word checked against aliases → replaced → expanded and run
For Shell & Bash → Aliases, continue with the first unproven Topic check: Check alias definition and whether alias expansion is enabled in the exact shell mode. If that boundary is healthy, advance to the adjacent check: Use type/command-resolution inspection to distinguish alias, function, builtin and external executable. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
shell mode/options → parse command word → alias lookup/recursive expansion → resulting shell tokens/expansions → command resolution → execution/result
Healthy evidence: alias presence and expansion mode are known, command resolution after expansion matches expectation and no policy depends on alias enforcement.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Check alias definition and whether alias expansion is enabled in the exact shell mode.
- Use type/command-resolution inspection to distinguish alias, function, builtin and external executable.
- Prefer functions/scripts for reusable argument-aware logic and policy controls for enforcement.
- Verify the actual command/argv executed in the target context rather than assuming interactive aliases apply.
Verification chain. shell mode/options → parse command word → alias lookup/recursive expansion → resulting shell tokens/expansions → command resolution → execution/result
Step 3 Commands Verify boundary
alias ll='ls -la'
alias
unalias ll
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: an alias is assumed to work in scripts, hides the real executable during troubleshooting or is treated as a safety/security control.
Step 5 Common mistakes Narrow the fault
- Using aliases in scripts (not expanded in non-interactive shells by default).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Aliases (rm='rm -i') can hide the real command; run \rm or command rm to bypass. Scripts do not expand aliases — use functions there.
bash -x script.sh— trace each expanded commandbash -n script.sh— syntax check onlyshellcheck script.sh— common bugs and quoting problemsecho $?— exit code of the last command
ReferenceWhat it is1 section · depth on demand
Core model
Alias expansion depends on shell mode/options and parse timing. It is commonly enabled in interactive shells and disabled in non-interactive shells unless expand_aliases is set; aliases do not behave like functions for arguments and can be bypassed by paths, command builtin, quoting or different shells.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
Alias verification shows convenience expansion in one shell context only; it does not establish script behavior, portability or security enforcement.
In depth
Aliases: what they're good for, and their limits
An alias replaces the first word of a command with a string. The bash(1) manual page sets clear limits:
- Aliases are expanded when a line is read, not when it's executed.
- They can't take arguments.
- They aren't expanded in non-interactive shells unless
expand_aliasesis set.
The manual itself states that shell functions are preferable to aliases for almost every purpose.
Typical aliases
| Alias | Purpose |
|---|---|
alias ll='ls -lh' | Shorter command |
alias rm='rm -i' | Safety prompt (only in interactive shells) |
alias k='kubectl' | Abbreviation |
alias grep='grep --color=auto' | Default options |
alias sudo='sudo ' | The trailing space lets the next word be alias-expanded too |
Alias or function?
| Need | Use |
|---|---|
| Just a shorter name or fixed options | Alias |
Arguments in the middle (ssh -t "$1" sudo -i) | Function |
| Logic, loops or conditions | Function |
| Use in scripts | Function (or the full command) |
Bypassing an alias
| Method | Effect |
|---|---|
\rm file | Run the command without its alias |
command rm file | Skip aliases and functions |
unalias rm | Remove for this shell |
Checking what a name is
type -a name shows every definition: alias, function, builtin or file in PATH. It's the right tool when a command behaves unexpectedly in your shell but not in someone else's.
host$ alias ll='ls -lh --group-directories-first'
host$ type -a ll ls
ll is aliased to `ls -lh --group-directories-first'
ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
host$ alias
host$ bash -c 'shopt expand_aliases; ll' 2>&1
expand_aliases off
bash: line 1: ll: command not found
host$ sshr() { ssh -t "$1" sudo -i; }
host$ \ls /etc/ssh | head -3
host$ unalias ll
Where to put them
Aliases belong in ~/.bashrc, or in ~/.bash_aliases if your distribution's bashrc sources that file. They're then defined in every interactive shell. A login shell only gets them if ~/.bash_profile sources ~/.bashrc.
Documented example, not captured output.
How it works at runtime
Aliases is part of Shell & Bash → Aliases. Bash Aliases perform interactive lexical command-name substitution during shell parsing and are primarily a convenience layer, not a reliable scripting or security mechanism.
Topic-specific state model. Bash Aliases perform interactive lexical command-name substitution during shell parsing and are primarily a convenience layer, not a reliable scripting or security mechanism.
Interpretation rule. - Alias exists interactively ≠ a script or non-interactive shell expands it.
- alias rm=... ≠ destructive rm is prevented; aliases are not an authorization boundary.
- Alias text ≠ function parameter handling.
- A command name displayed in history ≠ whether alias expansion changed what executed.
Quick reference
Aliases are interactive shortcuts; they are not expanded in scripts by default and do not take arguments (use functions for that).
alias ll='ls -alF'
alias rm='rm -i'
alias k=kubectl
unalias rm
alias # list
\ls # bypass alias once
command ls
Put personal aliases in ~/.bashrc (or ~/.bash_aliases on Debian/Ubuntu). Distribution aliases like rm -i for root on RHEL can surprise scripts copied from interactive sessions.
Limits and how it fails
Primary failure point. Alias verification shows convenience expansion in one shell context only; it does not establish script behavior, portability or security enforcement.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Functions owns argument-aware reusable shell logic; Bash startup files commonly define aliases; this Topic owns alias expansion and limitations.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Shell & Bash → Aliases. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.gnu.org/software/bash/manual/bash.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Aliases operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Aliases.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Bash Aliases perform interactive lexical command-name substitution during shell parsing and are primarily a convenience layer, not a reliable scripting or security mechanism. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host/distribution + shell/version/mode → identify cwd/mount namespace + input/path/stream → preserve quoting/expansion and final argv → map fd/pipeline/process boundaries → inspect object/variable/status/signal state → make one minimal reversible change → read back effective state → repeat original consumer/script/workload test. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | shell mode/options → parse command word → alias lookup/recursive expansion → resulting shell tokens/expansions → command resolution → execution/result | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Alias verification proves convenience expansion in one shell context only; it does not establish script behavior, portability or security enforcement. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux file/text/shell evidence can establish this proof path: shell mode/options → parse command word → alias lookup/recursive expansion → resulting shell tokens/expansions → command resolution → execution/result | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured host, shell/session, cwd/namespace, input, process, filesystem, locale, time or workload scope. Alias verification proves convenience expansion in one shell context only; it does not establish script behavior, portability or security enforcement. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven boundary: capture the exact shell-delivered argv/streams or resolved object, verify the effective target state, change only the demonstrated cause, then repeat the original consumer/script/workload and adjacent regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
Aliases · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Aliases |
|---|---|
| Topic path | Shell & Bash → Aliases |
| Runtime state | Bash Aliases perform interactive lexical command-name substitution during shell parsing and are primarily a convenience layer, not a reliable scripting or security mechanism. |
| Fast checks | - Check alias definition and whether alias expansion is enabled in the exact shell mode. - Use type/command-resolution inspection to distinguish alias, function, builtin and external executable. - Prefer functions/scripts for reusable argument-aware logic and policy controls for enforcement. - Verify the actual command/argv executed in the target context rather than assuming interactive aliases apply. |
| Verification chain | shell mode/options → parse command word → alias lookup/recursive expansion → resulting shell tokens/expansions → command resolution → execution/result Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | Alias verification proves convenience expansion in one shell context only; it does not establish script behavior, portability or security enforcement. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |