Server Fault is a question and answer site for system and network administrators. 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

Do the two different syntaxes do the same thing?

$ service apache2 restart

$ /etc/init.d/apache2 restart
share|improve this question
As a side note, the whole "service foo restart" thing annoys me because I don't have tab completion. – cjc Dec 30 '11 at 20:25
up vote 3 down vote accepted

Yes. The backward compatible /etc/init.d/ scripts basically run service myservice start/stop/retstart instead of doing anything themselves.

share|improve this answer

Service is nothing more than a shell script.

cat /sbin/service

At that top you will see it sets the SERVICEDIR to /etc/init.d.

The service script has a few other options such as


That loop over all services. But the name you pass to it is matched to the init.d script.

share|improve this answer


To be precise:

service  runs  a  System  V  init script in as predictable environment as possible,
removing most environment variables and with current working directory set to /.

(from service(8))

share|improve this answer

In a way, yes. Actually upstart jobs will give a warning if started with /etc/init.d/ while service command always works both for sys v init scripts as well as upstart jobs.

share|improve this answer

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.