7

Is there any real difference between /etc/init.d/networking restart and invoke-rc.d networking restart (Debian)?

  • 3
    There is also service networking restart. Unfortunately I don't know enough to give you a detailed comparison of the 3 methods, except that running the /etc/init.d/ script is more "low-level" than the others. – jw013 May 9 '12 at 12:06
7

What invoke-rc.d does is documented in its man page. It is a wrapper around running the init script directly, but it also applies a policy that may cause the command not to be run, based on the current runlevel and whether the daemon should be run in that runlevel.

By default, Debian does not differentiate between runlevels 2-5, but as the local administrator, you can change what is run in each runlevel. invoke-rc.d will honor these local policies and not start a daemon if the runlevel is wrong.

1

There is no real difference[1]. The invoke-rc.d command simply provides a nice convenient interface for running the init.d scripts, sparing you the onerous responsibility of typing in the full path to the script you want to run! Both invocations will achieve the same end result.

[1] Note that the invoke-rc.d command performs checks before invoking the requested service script to ensure it should be run - it guards against calling scripts in the wrong runlevel, etc, so in that sense, there is a difference - it protects you from shooting your feet somewhat. The man page should prove instructive in this regard.

0

Another easy method to perform the network restart is to create the following bash file, called in my case [net] ie: /etc/init.d/net

The script:

#!/bin/sh -e
invoke-rc.d networking stop ;  invoke-rc.d networking start ; ifup eth0 

#Add whatever interfaces you have installed. ie: ifup eth0 wlan0 etc 

After creation chmod 711 'the filename' [net]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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