How to unalias an alias

It is very usefull to know how to temporary unalias an alias. There are some cases when you really need to do that, in your Linux / Unix box.

I will explain this with a practical example:

I have aliased shutdown to do ‘shutdown -h now’:

$ alias shutdown='shutdown -h now'

Having this alias, it is enough to type shutdown in the terminal and my system will turn itself off instantly.

But if I need to schedule a shutdown at 20:00, for example: shutdown -h 20:00, the shutdown alias will mess up my scheduled shutdown. So I will have to unalias the shutdown alias first.

unalias shutdown will unalias my shutdown alias until I my first relogin:
$ unalias shutdown
And now I can use: $ sudo shutdown -h 20:00 .

The easiest solution to this problem is to escape the shutdown command with \ . The command \shutdown -h 20:00 will turn off my system at 20:00, ignoring my shutdown alias.

$ sudo \shutdown -h 20:00

The \ character before a command will tell the shell to use the system command, not an alias or function.

Tagged with: , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *




Subscribe to get the latest Linux news and how to guides directly on your e-mail!