Bash Shell Temporarily Disable an Alias

I have couple of shell aliases defined in ~/.bashrc file. How do I temporarily remove (disable) a shell alias and call the core command directly without using unalias command under a bash shell on a Linux or Unix-like systems?

An alias command enables a replacement of a word with another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. [donotprint][/donotprint]It is also useful for creating your own commands on a Linux, OS X, FreeBSD, OpenBSD, Ubuntu/Debian/Red hat/CentOS/Fedora and Unix-like operating systems.

How to display currently defined aliases

Type the following command:
$ alias
Sample outputs:

How to create an alias

Create an alias called c for the commonly used clear command, which clear the screen:
$ alias c='clear'
Then, to clear the screen, instead of typing clear, the user would only have to type the letter c and press the [ENTER] key:
$ c

How do I disabled alias temporarily?

An alias can be disabled temporarily and the core command get called directly. Just prefix command with a backslash. Create an alias called vnstat:
$ alias vnstat='vnstat -i eth1'
$ vnstat

Sample output:

Database updated: Fri Mar 13 15:30:01 2009


	   received:     158.48 GB (20.9%)
	transmitted:     599.82 GB (79.1%)
	      total:     758.30 GB

	                rx     |     tx     |  total
	yesterday      2.83 GB |   10.90 GB |   13.73 GB
	    today      1.92 GB |    7.31 GB |    9.23 GB
	estimated      2.97 GB |   11.28 GB |   14.25 GB

Now disabled vnstat alias temporarily, enter:
$ vnstat
Sample output:

                     rx      /     tx      /    total    /  estimated
     yesterday      2.83 GB  /   10.90 GB  /   13.73 GB
         today      1.92 GB  /    7.31 GB  /    9.23 GB  /   14.24 GB

     yesterday    655.05 MB  /    2.02 GB  /    2.66 GB
         today    438.01 MB  /    1.43 GB  /    1.86 GB  /    2.86 GB

Another option is to type full command path:
$ /usr/bin/vnstat
You can also use any one of the following command too:
$ "vnstat"
$ 'vnstat'
$ command vnstat

But, how do I unalias permanently?

Update your shell configuration file like ~/.bashrc and remove required alias:
$ vi ~/.bashrc #or use joe text editor ##
$ unalias nameHere
$ unalias vnstat
$ source ~/.bashrc

For more info read the following help/man pages:
$ man bash
$ help source
$ help alias
$ help unalias
$ man vim

See also

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.