Fundamentals 2 min read

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.

Open Source Linux
Open Source Linux
Open Source Linux
Mastering the unalias Command: How to Remove Shell Aliases Quickly

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 -a

Notes

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

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Bashcommand-lineAliasunalias
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.