Service Command for Ubuntu

Have you ever wanted to have more simpler command in Ubuntu linux then running “sudo /etc/init.d/samba restart” for example. Well now you can, I’ve wrote small function that does just that. It’s very simple function, which you need to put in your /home/USER/.bashrc (or optionally in .bash_aliases file if you use one).

Here is the function for .bashrc

1
2
3
function service() {
  sudo /etc/init.d/$1 $2;
}

To use it simply open your bash shell window and type:

1
service samba restart

or whatever service you need to restart

Possible options are:

1
2
3
4
5
6
service daemon start
service daemon stop
service daemon reload
service daemon restart
service daemon force-reload
service daemon status

Where is “daemon” is the linux service you need to use.


Leave a comment

Your comment

Yandex Mail.ru Google LiveJournal myOpenId Flickr claimId Blogger Wordpress OpenID Yahoo Technorati Vidoop Verisign AOL