Remove an Alias


unalias

All good things must come to an end, and sometimes an alias outlives its usefulness. To remove an alias, use the unalias command.

$ ls -d */ by_pool/  libby_pix/  on_floor/ $ alias lsd= 'ls -d */' $ lsd by_pool/  libby_pix/  on_floor/ $ unalias lsd $ lsd $ 


Note, though, that this command only works permanently for temporary shell aliases, discussed previously in "Create a New Temporary Alias." The lsd alias in the previous example is gone for good. If you use the unalias command on an alias found in .bash_aliases, it too will be gone, but only as long as you're logged in. When you log out and log back in, or reload .bash_aliases, the alias is back.

To remove aliases from .bash_aliases, you need to edit the file and manually remove the line containing the alias. If you think there's a chance you might want to reuse the alias again sometime, just put a pound sign (which comments it out) in front of the alias, like this:

# alias lsd= 'ls -d */' 


Save .bash_aliases, reload it with the . .bash_aliases command, and the alias won't work any longer. But if you ever need it again, open .bash_aliases, remove the pound sign, save and reload the file, and it's good to go again.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net