Clear all Linux / UNIX bash shell aliases

How do I clear all Linux and UNIX bash shell aliases in single command? I have twenty bash shell aliases defined and I just need to delete them in a current session. How do I get rid of all of them?

You need to use unalias command on Linux or Unix to remove bash shell aliases. The alias command used to create aliases. It works on bash, ksh, csh and other Unix shells. This page shows how to clear or remove bash shell alises using command-line options.

How to see a list of bash shell aliases

To get a list of aliases for the current user, run:
alias -p

How to defined a new bash shell alias

The syntax is:
alias name='value'
The following command create a new alias named c for the commonly used clear command:
alias c='clear'
Next, to clear the screen, instead of typing clear, the user would only have to type the letter c and press the ENTER key:
In this example, when user type nano, open a text editor named vim:
alias nano='vim'

unalias command syntax to remove aliases

The syntax is:
unalias name
unalias [option] name

To remove alias called foo, enter:
unalias foo
To clear alias named c, enter:
unalias c
Please note that alias command with no arguments or with the -p option prints the list of aliases:
$ alias
Sample outputs:

alias ll='ls -lh'
alias ls='ls --color=auto'
alias vi='vim '
alias c='clear'
alias d="/usr/local/bin/chkdomain [email protected]"

How to clear all Linux / UNIX bash shell aliases

To remove all bash shell aliases NAMEs from the list of defined aliases pass the -a option as follows and it will remove all alias definitions:
unalias -a
Verify it:
Above command removed all bash shell alias.

Sample Linux session that remove all bash shell aliases

How to remove or clear all Linux and Unix bash shell aliases

Getting help of alias and unalias command

Visit this page or type the following commands:
help alias
help unalias
man alias

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts