I would like to know which is the right method to restart networking service in Debian Jessie.
I know that I can use:
service networking restart
or
/etc/init.d/networking restart
that anyway gave me problems on ssh connection, or
invoke-rc.d networking restart
and other two methods with systemctl and with ifup/ifdown.
But which is the right way to do it?
Best Answer
I would use the
service
command because it is more consistent across different distributions. So of the commands you mentioned, the variant I would go for is:And I would definitely run it inside a
screen
session or by other means ensure that it won't fail to complete in case you lost connection with the shell in which you typed it. (I have tried losing connectivity to a machine by logging in withssh
and then restarting the network only to have the ssh connection terminate while the network was down and send a HUP toservice
such that it would not bring up the network again.)In the past there have been systems where
service
was a simple wrapper around the scripts in/etc/init.d
and the first two of your commands would do the exact same thing. But nowadays there are systems whereservice
will sometimes do something different, and in generalservice
knows better what to do on your particular distribution. Andinvoke-rc.d
is also distribution dependent.Though
service
is the most similar across distributions, it is still possible for the service names to be different. For example there are distributions where the service is namednetwork
and others where it is namednetworking
. And in some configurations it may be more appropriate to restartnetwork-manager
rather thannetworking
.