I am new to linux and have been testing myself using an Amazon Lightsail instance (Ubuntu 16.04 LTS).
Going through the many guides I have came across, I see people using different commands to start/stop/restart/reload/status-check a service. Specifically these;
sudo systemctl status apache2.service sudo /bin/systemctl status apache2.service sudo /etc/init.d/apache2 status sudo service apache2 status
All the above commands work.
- Should I prefer one command over the other?
- If yes then why?
- Are there any other commands I need to be aware of?
Using init.d in Monit caused issues when I wanted to use the status option (status will be that the service is offline when it was actually online — restarted by Monit). Change the code in Monit from inid.d to /bin/systemctl fixed it.
It seems that using init.d provides more information on what happened that the others. If I should be using one of the other commands, is it possible to have them display more information on what was done?
ubuntu@ip-172-26-12-245:~$ sudo systemctl restart pure-ftpd.service ubuntu@ip-172-26-12-245:~$ sudo /bin/systemctl restart pure-ftpd.service ubuntu@ip-172-26-12-245:~$ sudo /etc/init.d/pure-ftpd restart [ ok ] Restarting pure-ftpd (via systemctl): pure-ftpd.service. ubuntu@ip-172-26-12-245:~$ sudo service pure-ftpd restart ubuntu@ip-172-26-12-245:~$
I would like to thank everyone in advance who has taken the time to read and reply to this question.