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.

ADVERTISEMENTS

How to see a list of bash shell aliases

To get a list of aliases for the current user, run:
alias
OR
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:
c
In this example, when user type nano, open a text editor named vim:
alias nano='vim'
nano

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 $@"

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:
alias
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

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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
3 comments… add one
  • vinod kumar Jul 26, 2007 @ 6:46

    Where to check common error in logs

  • vinod Jul 27, 2007 @ 10:04

    How to find and install a new hardware

  • CMREDDY Sep 28, 2012 @ 7:08

    how i can fixed the alias commands on a terminal..

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.