Issue
I have two virtual machines with Debian. One I got from school. The other one I made myself.
The way you restart apache2 on the school machine is service apache2 restart
and they way you restart networking is service networking restart
.
However, when I tried these commands in the machine I set up myself, I found out that they don't work and that I have to use systemctl apache2 restart
for apache2 and systemctl restart networking
for networking instead.
My question is why I have two use two different commands to do the same thing on these machines, even tho they are both running Debian.
Thank you in advance.
Solution
The answer to your question: On the machine, you set up for yourself, you have a newer distribution of Debian than the one from your school. The service command was replaced with systemctl .
A more detailed answer with differences between these two commands you can find here.
In the older versions, for the same task we used:
/etc/init.d/{service name} {comand}
example:
/etc/init.d/apache2 restart
Then at a later stage, the service command came in.
Now on current distributions, you should use systemctl instead of service, and it is recomended even on distributions what suport both or all three comands (like ubuntu 20.04 for example).
Answered By - Lorand Answer Checked By - Robin (WPSolving Admin)