unalias command in Linux and it perimeters

unalias command in Linux and it perimeters

In Linux, the unalias command is used to remove aliases previously defined by the user. Aliases are custom shorthand commands that allow you to create shorter or more convenient names for frequently used commands. The unalias command helps you to delete these custom aliases, restoring the original behavior of the commands.

The basic syntax of the unalias command is:

Bash
unalias [alias_name]

Here is a table outlining the parameters of the unalias command:

ParameterDescription
[alias_name]Optional. Specifies the name of the alias you want to remove. If not provided, the unalias command will display a list of currently defined aliases and prompt you to choose one to remove.
ParameterDescription
-aRemoves all aliases.
-rRemoves the specified alias.

Examples:

  1. Remove the alias for ll (previously defined as ls -lh --color=auto):
Bash
unalias ll
  1. Delete an alias called cls (previously defined as clear):
Bash
unalias cls
  1. Remove an alias named desktop (previously defined as cd ~/Desktop):
Bash
unalias desktop
  1. Delete an alias called psa (previously defined as ps -aux):
Bash
unalias psa
  1. Display a list of currently defined aliases and prompt to remove one:
Bash
unalias

Sample output:

Bash
alias ll='ls -lh --color=auto'
alias cls='clear'
alias desktop='cd ~/Desktop'
...

Choose an alias to remove (e.g., enter ll to remove the ll alias).

  1. Attempt to remove a non-existing alias (no error occurs if the alias does not exist):
Bash
unalias non_existing_alias

# Create an alias for the ls command called lsdir
alias lsdir='ls -al'

# Use the lsdir alias
lsdir

# Remove the lsdir alias
unalias lsdir

# Try to use the lsdir alias again
lsdir

The second time you run the lsdir command, you will get an error message because the alias has been removed.

The unalias command is useful for managing aliases and cleaning up your shell environment by removing aliases you no longer need or want to revert to the default behavior of specific commands.

Total
0
Shares

Leave a Reply

Previous Post
type command in Linux and it perimeters

type command in Linux and it perimeters

Next Post
cd command in Linux and it perimeters

cd command in Linux and it perimeters

Related Posts