Difference between Systemctl and service command

Roman Romanov picture Roman Romanov · Apr 21, 2017 · Viewed 17.8k times · Source

I always run my Apache server in this way:

sudo service apache2 start

But in many guides I saw commands like this:

sudo systemctl start apache2

Can somebody shortly write the difference between these commands and give me advice about what command I should use in everyday work?

Answer

shahin picture shahin · Apr 21, 2017

service operates on the files in /etc/init.d and was used in conjunction with the old init system. systemctl operates on the files in /lib/systemd. If there is a file for your service in /lib/systemd it will use that first and if not it will fall back to the file in /etc/init.d. Also If you are using OS like ubuntu-14.04 only service command will be available.

So if systemctl is available ,it will be better to use it