Bash Wiki
Posts (Latest 30 updated) :
Read all
Contents:
  1. [Linux] Bash unalias uso: Remove aliases in the current shell session
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
      1. Remove a Specific Alias
      2. Remove Multiple Aliases
      3. Remove All Aliases
      4. Remove Aliases Matching a Pattern
    5. Tips

[Linux] Bash unalias uso: Remove aliases in the current shell session

Overview

The unalias command in Bash is used to remove existing aliases from the current shell session. Aliases are shortcuts that allow users to create custom commands or modify existing ones for convenience. When you no longer need an alias, unalias helps to clean up your environment.

Usage

The basic syntax of the unalias command is as follows:

unalias [options] [arguments]

Common Options

  • -a: Remove all aliases defined in the current shell session.
  • -m: Remove aliases that match a specified pattern.

Common Examples

Remove a Specific Alias

To remove a specific alias, use the alias name as an argument:

unalias ll

Remove Multiple Aliases

You can remove multiple aliases by listing them:

unalias ll grep

Remove All Aliases

To remove all aliases at once, use the -a option:

unalias -a

Remove Aliases Matching a Pattern

To remove aliases that match a certain pattern, use the -m option:

unalias -m 'g*'

Tips

  • Always check your current aliases with the alias command before removing them to avoid accidentally deleting something important.
  • Consider using unalias -a with caution, as it will remove all aliases and may disrupt your workflow.
  • If you want to make sure an alias is removed every time you start a new session, consider adding the unalias command to your shell’s configuration file (like .bashrc or .bash_profile).