A service or daemon is a memory-resident program that runs in the background. Your operating system will typically start it at boot (although not always) and continue to run it without any intervention on your part. Some common services usually running on a Linux dedicated server are: web server (such as Apache), database server (such as MySQL), mail server (such as Postfix), and DNS server (such as Bind).
There are many reasons why you might want to start, stop, or restart services, particularly after upgrades, reconfiguration, or unexplained stoppage.
Since nearly all services on a server will run under a username other than your own, you will need to log in as root to control them:
You can then type the following formula to start a service:
To stop the same service, type:
There are other commands you can use with the same formula:
status – tells you the current state of the service, if it is running, dead, stopped, etc.
restart – used to restart a currently running service
reload – not available with all services, but with some, it involves a complete reload of all files and child processes.
On some operating systems, such as Red Hat Enterprise Linux, CentOS, and Fedora, you can type “service” followed by the service name, rather than the entire path. For example, to restart Apache:
service httpd restart
Always keep in mind that, on a live server, starting or stopping services can directly affect the hosted websites. Although any outage is usually quick, it is best to save tweaking, troubleshooting, and testing for low traffic hours.