I am new to linux and trying to create an alias that starts mongodb service.
The original command is sudo service mongod start
. I want to generalise this usage for any service.
i.e. something like alias startservice="echo <password> | sudo -S $1 start"
.
So I would call it like startservice mongod
should run the first command. I came to know that I can use functions for the same. However, I don't have a clue on how to do this either way.
Because I want my function which I create to be able to be accessible across terminals. I am not sure on how to create functions that act in this manner. Please help me on this.
I have gone through these two links:
parameter subsitution in bash aliases
Alias with Argument in Bash - Mac
Your help would be appreciated.