Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I am having this problem: http://stackoverflow.com/questions/10939072/add-nginx-as-a-ubuntu-service-stop-and-reload-doesnt-work

I am trying to understand if my code to start nginx is point to the same PID file as my nginx.conf file.

How do I know what code runs when I type sudo service nginx start ?

share|improve this question
up vote 7 down vote accepted

The sudo part just starts the rest with root priviliges.

The manual pages for service say that


executes a System V init script located in /etc/init.d/SCRIPT or, in case of the system using Upstart, an upstart job in /etc/init.

If you have both:

The existence of an upstart job of the same name as a script in /etc/init.d will cause the upstart job to take precedence over the init.d script.

The handling of COMMAND depends on whether an init script or an upstart job is invoked.

share|improve this answer
AFAIK system doesn't know anything about upstart, and diverting to upstart is done via a sourced script in the init script. Modern system is systemd aware though. – jordanm Mar 11 '14 at 19:00
@jordanm why the reference to system the OP asks about service AFAIK and at least on my Ubuntu system it tries system V or upstart scripts. – Anthon Mar 11 '14 at 19:06
sorry, I meant service. It tries upstart because of init_is_upstart() in /lib/lsb/init-functions. – jordanm Mar 11 '14 at 19:54
@jordanm I was not aware of how upstart hooks into the service, just referring to what the man page for service describes (on Ubuntu 12.04). – Anthon Mar 11 '14 at 20:29

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.