Run a script via Alias Command - CentOS & Red HAT

Its possible to run a script via Alias command. All you need is to modify the .bashrc and then source the script in the required user profile. Alias commands are very useful when it comes to running shortened versions of commands or a complex script to be run using just a single line of command. Currently I use this to run 2 of my custom scripts for waking up a ESXi server via WOL (Wake-ON-LAN).

All you need to do this first create (or) select a script you want to run as an Alias Command.

I have got 2 scripts located in /home/pi/


Now go ahead and edit the .bashrc file for a user who wants to run the command. In this case the user is 'pi' and file is "/home/pi/.bashrc".

Edit "/home/pi/.bashrc"

# vi /home/pi/.bashrc

Add the above 2 scripts to the end of the file so that they can be called by the command "wakie-esxi"

alias wakie-esxi='source /home/pi/ && /home/pi/'

And then you can either log-off and login back for the changes to take effect (or) if you want to apply the changes on the fly without logging off then run this command as given below.

# source /home/pi/.bashrc

And that should be it and you should be able to call scripts via Alias commands.


pi@rasst ~ $ wakie-esxi
hppl-1 is UP as on Mon Feb  8 09:36:16 GMT 2016
hppl-2 is UP as on Mon Feb  8 09:36:17 GMT 2016

If any issues please let us know via Contact Us and we will try our best to help you out.

Linux Related Articles . . .

To generate a SHA256 certficate in linux all you need to do is run this openssl command and you will...
This a very useful One liner command to insert IP and hostname into /etc/hosts file and is particularly useful when...
Its possible to use awk in Alias command. I did that by simply just modifying some parenthesis and there you...
Its possible to run a script via Alias command. All you need is to modify the .bashrc and then source...
This article will guide you on creating a custom Self-signed SSL Certificate in no time. For creating one you would...