The above commands can be run on CentOS, Ubuntu, Redhat, Fedora, Debian, and many more. The service would restart and you’d be returned to the bash prompt. To restart the same service, we’d issue the command:
The service would start and you’d be returned to your bash prompt. To start the same service, we’d issue the command: The Apache server would stop and you’d be returned to the bash prompt. To do this we’d open up a terminal window and issue the command: Let’s say we’re on CentOS and we want to stop the Apache server. In fact, the stopping|starting|restarting of services on Linux is now quite simple. To complicate matters more, you might find a random service you’ve installed that hasn’t been updated to either the service or systemctl tools and have to manually start it from with /etc/rc.d (or /etc/init.d).īut we’re looking for best practices here and for starting|stopping|restarting applications on Linux, best practices begin and end with systemctl. Fortunately, the developers of systemd made sure to retain service and redirect it to systemctl. However, old habits die hard, so many administrators still hold onto the aging service command. Most modern distributions have made the switch to systemd, so systemctl is the service manager of choice. Which one you use will depend on if your distribution makes use of systemd or init. There are two officially adopted methods for controlling services: Even then, you might be able to control those services via multiple means. How you start|stop|restart a service will depend upon whether your distribution uses systemd or init.
Linux turns 30: Celebrating the open source operating system (free PDF) One of the most beautiful and user friendly Linux distributions gets even better Open source: Must-read coverageīecome a Linux expert just in time for the 2022 boomĥ things Linux needs to seriously compete in the desktop market that you probably never considered Even better, it has (for the most part) become universal. How a service is stopped, started, and restarted now makes perfect sense. When working between Redhat and Debian distributions, that had a tendency to get confusing I’d try to issue /etc/rc.d/service start on one distribution, only to find out it should have been /etc/init.d/service start. I remember, back in the day, to start or stop a Linux service, I’d have to open a terminal window, change into the /etc/rc.d/ (or /etc/init.d, depending upon which distribution I was using), locate the service, and the issue the command /etc/rc.d/SERVICE start|stop|restart (Where SERVICE is the name of the service to be started, stopped, or restarted). And that list grows longer and more complicated every day. As a systems administrator, you are tasked to handle quite a lot.