Using Unalias to Remove an Alias
September 8, 2006 – 10:13 amI have been using Linux for several years now, and invariably, every couple of months I learn something that I really feel like I should have learned a long, long time ago. Today was one such instance. I use the alias feature quite a bit via my BASH shell. I use it to ease in SSH’ing (e.g. instead of ssh myusername@hostname.domainname.com I have a setup where alias hostname='ssh myusername@hostname.domainname.com' so that I can just type hostname to SSH where I want). I use it for plenty of other things as well.
Well, today was the first time I ran into the problem of having an existing alias that was causing me problems. I just wanted to remove it. I had no idea how to do that. Specifically, when I run Matlab, I run it with the Java Virtual Machine and the initial splash screen disabled, which would traditionally be called with matlab -nojvm -nosplash. In my .bashrc file, I had alias matlab='matlab -nojvm -nosplash'. But today I wanted the Java Virtual Machine enabled. What to do?
Two quick Google searches yielded nothing, but a third search finally got me close enough to reveal the command for which I was looking: unalias. How easy is that? A quick unalias matlab, and my Matlab alias disappeared. Why didn’t I just guess that? Even more embarrassing, I did a man alias, and the man page was long enough (and general enough) that I just disregarded it. Sure enough, unalias is sitting right in there. If I have had the proper patience, I could have found it right there.
So, consider this a present to all of those souls like myself who lack patience or have failed to learn things they probably should already know. If you want to clear or remove an alias, unalias is your friend.