Making an Alias to Shutdown Ubuntu

Ubuntu is a widely used operating system because of its versatile features and security. Most of the professional programmers like to work on it but we don’t like to waste our time when it comes to performing basic functions of the computer through GUI. In this article, we will write an alias to Shutdown a computer using just a single word.

alias shut='echo  | sudo -S shutdown now'

In this command, we need to put our password and it will pass it to sudo command while running so you don’t need to put it manually each and every time. As we need root privileges to shutdown our system so we are using sudo, ‘now’ after shutdown command shows we don’t want to wait or set any particular time at which we’d want our system to turn off. We can set particular time as well, Also if we use ‘shutdown -h’, It will shut down exactly after 1 minute.
Alias command is being used to tell our system that whenever we put command ‘shut‘, We’d like it to run this lengthy code.



As alias are not permanent and often session-oriented so we need to put it in .bashrc file to make this alias permanent. To open the .bashrc file in vim, We’ve to use this command ‘vim ~/.bashrc’
Once we are into our bashrc, We need to put this whole alias into the bunch of aliases present in it and to save and quit the .bashrc we need to use :wq command. This command is now bash oriented and will work for every session.


Whenever we will use shut on our terminal, It will shut down our system immediately!



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.