4

I had an alias in my .bashrc and I really don't want it anymore. I erased the alias, but my bash already has this alias loaded.

Can I erase this alias from this bash without logging out?

4
  • For questions like these, try Google next time. It works.
    – mmtauqir
    Apr 22, 2013 at 14:51
  • I did... didn't work
    – RSFalcon7
    Apr 22, 2013 at 14:52
  • Oh ... I tried searching on Google using keywords from your question: erase alias bash. It worked. Not a big deal, just a humble suggestion.
    – mmtauqir
    Apr 22, 2013 at 14:54
  • @mtahmed good for you! Even being not a hard question, this it is a positive thing to the community because now those keywords will most likely end up here. I tried erase alias bash without logout ftw
    – RSFalcon7
    Apr 22, 2013 at 14:59

3 Answers 3

7

by using unalias:

[zak ~]$ alias ls
alias ls='ls --color=auto'
[zak ~]$ unalias ls
[zak ~]$ alias ls
bash: alias: ls: not found
5

Use the unalias command:

$ alias foo=ls
$ foo
... ls output ...
$ unalias foo
$ foo
bash: foo: command not found
4

If you have many aliases and wish to clear them all, run unalias -a. Then you can source your .bashrc (or .bash_aliases) file to use the aliases there.

$ unalias -a
$ # '.' is like an alias to 'source'
$ . ~/.bashrc

Sometimes it is desirable to disable an alias temporarily instead of unaliasing it entirely. To do this, put a \ in front of your command.

$ alias foo=ls
$ foo
... ls output ...
$ \foo
bash: foo: command not found
$ foo
... ls output ...

Not the answer you're looking for? Browse other questions tagged or ask your own question.