Mastering the unalias Command: How to Remove Shell Aliases Quickly
This guide explains how to use the built‑in unalias command in Bash to delete individual or all command aliases, shows the syntax and common options, provides practical examples, and highlights important considerations when running scripts that modify alias settings.
unalias: Remove Command Aliases
Function Description
unalias is a built‑in shell command used to delete command aliases. Provide the alias name as an argument to remove a specific alias, or use the -a option to delete all defined aliases.
Command Syntax
unalias [options] [alias]Common Options
-a: Cancel all defined aliases
Example Usage
(1) Remove a single alias
// Set an alias first
# alias ok='pwd'
# ok
/root
// Remove the alias
# unalias ok
# ok
-bash: ok: command not found(2) Remove all aliases
# unalias -aNotes
(1) When running scripts, be aware that using source to execute a Bash script that contains alias or unalias may affect the current terminal’s alias settings, potentially altering command behavior.
(2) To view or set aliases, use the alias command.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
