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:
service networking restart
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 with ssh
and then restarting the network only to have the ssh connection terminate while the network was down and send a HUP to service
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 where service
will sometimes do something different, and in general service
knows better what to do on your particular distribution. And invoke-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 named network
and others where it is named networking
. And in some configurations it may be more appropriate to restart network-manager
rather than networking
.