Systemctl vs service: Which command should you use?

Systemctl and service are both commands used to manage system services on Linux. However, there are some key differences between the two commands.

Systemctl is a more modern and comprehensive command that is built on top of systemd, the system and service manager for most Linux distributions. Systemctl can be used to start, stop, restart, enable, disable, and check the status of system services. Systemctl can also be used to manage other system units, such as sockets, timers, and device nodes.

Service is an older command that is used to manage system services under System V init, the previous system and service manager for Linux. Service is still available on most Linux distributions, but it is recommended to use systemctl instead, as it is more powerful and flexible.

Here is a table that summarizes the key differences between systemctl and service:

FeatureSystemctlService
Built onsystemdSystem V init
Commandsstart, stop, restart, enable, disable, status, and morestart, stop, restart, enable, disable, and status
Can manageSystem services, sockets, timers, and device nodesSystem services only
RecommendedYesNo(in latest OS)

drive_spreadsheetExport to Sheets

When should you use systemctl?

You should use systemctl when you need to manage system services, sockets, timers, or device nodes. Systemctl is also the recommended command for managing system services on most Linux distributions.

When should you use service?

You should use service only if you need to manage system services on a legacy Linux system that does not have systemd.

Example

The following example shows how to use systemctl to start the Apache web server:

systemctl start httpd.service

The following example shows how to use service to start the Apache web server:

service httpd start

As per my previous blog on How to install docker, you can see how the systemctl & service shows the output on Ubuntu.

Conclusion

Systemctl is a more modern and comprehensive command for managing system services on Linux. It is recommended to use systemctl instead of service, unless you need to manage system services on a legacy Linux system that does not have systemd.

I hope this blog post has been helpful.