Monday, February 10, 2014

Service Command in Linux

Services are the daemon programs that run behind without an associated console. So we can't control these daemon services through some GUI. For these daemon services, the command service is useful to control them. The service command controls the Starting, Stopping and Restarting of services.

Service command runs a System V init script or upstart jobs. The service command runs the script which is located in /etc/init.d/script or the name of the upstart jobs is located in /etc/init. The service command calls the init script and returns the status returned by it. This command makes it possible to start, restart or stop a service without restarting the system, for the changes to be taken into effect. Most of the important services listen for the network connections from the clients, which request to perform some action or to provide some information. Like the services, apache-Web Server, lpd- controls the printer,exim- mail transfer agent etc.

So, if some of the network services fails, and you want to start it again or some of the services if working abruptly then you may want to stop the services or restart the service that is to stop and start again.

So to start the service, type command as follows:

       service servicename start

To stop the service, type command as follows:

       service servicename stop

To restart the service, type command as follows:

       service servicename restart

 You can use the command to see the status of the services:

       service –status-all