Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every time I want t use this software I have to type /etc/init.d/kerio-kvc {start|stop|restart} in terminal. How can I define a shortcut command in terminal to do that?

share|improve this question
up vote 3 down vote accepted

Although the above works, you will need to write 3 aliases.

Instead I suggest you use a function (assuming sudo is needed)

function kerio ()
    case "$1" in
        start) sudo /etc/init.d/kerio-kvc start ;;
        stop) sudo /etc/init.d/kerio-kvc stop ;;
        restart) sudo /etc/init.d/kerio-kvc restart ;;
        *) echo 'usage kerio {start|stop|restart}' ;;
share|improve this answer

Open the bashrc file on your /home

nano ~/.bashrc

Then create an alias for what you want, on the end of the file. Like:

alias startkerio='/etc/init.d/kerio-kvc start'

Oh, and to be possible to use your new command without relogging or rebooting do this:

source ~/.bashrc
share|improve this answer
But there's problem with promission and sudo doesn't work What should I do? – Hamid FzM Dec 12 '13 at 22:27
The problem is when you try to save the file? If it is, it's a case of not having write permissions, so do this: 'chmod +w ~/.bashrc' If it's not the case, put the result of 'ls -l ~/.bashrc' here – Henrique Ferreira Dec 12 '13 at 22:34
No, when I try startkerio terminal wanted permission and sudo doesn't work! – Hamid FzM Dec 12 '13 at 22:45
Well,you must see the permissions of /etc/init.d/kerio-kvc because that's what asking for a permission. Does kerio-kvc works with sudo when it's executed directly? – Henrique Ferreira Dec 12 '13 at 22:59

You most likely should create a script that do that for you. Create a file somewhere in /usr/sbin, lets call it script (you can change it) then, edit it and include the following:

 /etc/init.d/kerio-kvc "$@"


For this method I'm going to use the SETUID, which is extremally dangerous if you don't know what you are doing. That said continue.

Now, lets set some nasty things like setting up our permissions of read and execution:

sudo chown root:root /usr/sbin/script
sudo chmod a-w /usr/sbin/script
sudo chmod a+x /usr/sbin/script
sudo chmod u+s /usr/sbin/script

Done. Now run script {start|stop|restart} anywhere and there it's.

share|improve this answer
I would put the script in /usr/local/sbin and there is no need to setuid, just call the script with sudo (Just my 2c) – bodhi.zazen Dec 13 '13 at 3:21
@bodhi.zazen well, I'm trying to get him with the less keystrokes possible – Braiam Dec 13 '13 at 13:27
so use a one or two letter alias rather then suggesting a security risk to save a few key strokes =) at least you added a caution. – bodhi.zazen Dec 13 '13 at 16:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.