Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Aliases

Direct 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.

When to use this

Use it for interactive shortcuts, or when a command behaves unexpectedly because an alias changes it.

First 30 seconds

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.

Operational verification

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

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it for interactive shortcuts, or when a command behaves unexpectedly because an alias changes it.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points

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

Key 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
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_aliases is set.

The manual itself states that shell functions are preferable to aliases for almost every purpose.

Typical aliases

AliasPurpose
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?

NeedUse
Just a shorter name or fixed optionsAlias
Arguments in the middle (ssh -t "$1" sudo -i)Function
Logic, loops or conditionsFunction
Use in scriptsFunction (or the full command)

Bypassing an alias

MethodEffect
\rm fileRun the command without its alias
command rm fileSkip aliases and functions
unalias rmRemove 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
bash aliasesalias command linuxexpand_aliasesshell alias
Embedded reference data

Quick lookup tables

Aliases operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Aliases.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateBash 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 verificationPin 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 chainshell mode/options → parse command word → alias lookup/recursive expansion → resulting shell tokens/expansions → command resolution → execution/resultTrace requested/configured state through effective state to the observed workload result.
Failure boundaryAlias 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 evidenceCorrelated 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/resultUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundaryAliases
Topic pathShell & Bash → Aliases
Runtime stateBash 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 chainshell 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 boundaryAlias 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 ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?