Linux ’service’ command

April 30th, 2010

It seems some Distributions of Linux don't include the 'service' command. Unfortunately, many great Tutorials assume this command is available, and use it for things like stopping and starting Apache, etc.

Luckily, it's a pretty simple script, and something you can easily create yourself. I use the nano text editor here, but feel free to replace 'nano -w' with 'vi' or whatever your preferred text editor is.

# nano -w /usr/sbin/service

In your Text Editor, enter this text:

#!/bin/sh
set -e
/etc/init.d/$1 $2 $3

Save the file, and then...

# chmod 755 /usr/sbin/service

This makes service an executable file.

Now you'll be able to do things like:

service httpd restart
service mysqld stop

easily!

Add a Comment:

 

Musings on Coding, Gaming, and Life in General
Loading...