unalias removes / disables an alias for the current session, that is, an alias is temporally disabled. If an alias is wrong, undesired or no more useful, I simply delete it from .bashrc or .bash_alias and source ~/.bashrc or close and reopen my terminal.

A usage I have found for unalias was when, after creating an alias in my .bash_aliases, I decided to change the alias to a function. That is, I have changed alias dothis="action" to dothis () { echo "some text"; action1; action2; }. But source ~/.bashrc kept on returning a syntax error near unexpected token (' that I couldn't fix, until I figured out that the error was coming from the fact I was using the same name for the original alias and the newly created function (sounds like an obvious error but not so at first sight). The error was gone after I unaliased the original alias: unalias dothis.

Besides this case, in which situations one would need / want to unalias?

  • 1
    The first line of your question is the answer. Also, alias can be defined in a live terminal session. You can't delete that without unalias.
    – Munir
    Feb 24, 2017 at 3:10

1 Answer 1


If an alias is wrong, undesired or no more useful, I simply delete it from .bashrc or .bash_alias and source ~/.bashrc or close and reopen my terminal.

"Why would I want to wash my hands if I can just take a shower"?

Oftentimes that is an impossible or an undesirable action. For instance, suppose you had a bunch of processes running in the background in the current shell which will die if you close it, or imagine you were working on a remote machine, so relaunching the session will require you to re-establish the connection, type in your credentials, and in some cases struggle with two-step authentification.

Also, if you are just "visiting" a system which you don't have a set-up environment in (to troubleshoot someone's problems, for instance), and you are not particularily fond of their idea of making ls into an alias for less for instance, it is so much easier to say unalias ls rather than argue with the user about re-launching the session and editing their configs, or sufferring the bindings you don't like.


I simply delete it from .bashrc or .bash_alias and source ~/.bashrc

That will not rid you of the existing aliases, unless you do unalias -a first.

  • @vovik: good points; considering (maybe wrongly) unalias a rare enough action or one that could be postponed, I've never dealt, nor thought about dealing with (un)aliases while having processes running in the background (I'd use screen for these) or being logged in to some remote machine.
    – calocedrus
    Mar 1, 2017 at 14:15
  • Also, nice and clearly illustrated metaphor about "washing hands" vs "taking a shower" for unalias vs delete (or comment) + close and repoen terminal; but some situations I meant to refer to as an introduction (permanently removing an alias, i.e. for future sessions) call for taking the shower rather than facing the need to repeatedly washing hands each and every time a new session is opened or one logs out and back in (or is there other options to permanently unalias?).
    – calocedrus
    Mar 1, 2017 at 14:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .