Basic Service Management

In this post I will show you some quick and easy ways to show all services that are running, as-well as how to stop, start, restart, checking service status, enabling/disabling services during startup, and finding service related processes. I will be using apache2 as my go to for this example but you can simply substitute apache2 with whatever service suits your needs.

Some Linux distributions will give you a confirmation message when you start/stop/restart a service, some will simply do it. If you need a confirmation message but don’t get one you can simply add “&& echo Success” to the end of the command. The distribution I am using for example will not give a message so this is what I am doing for the purpose of this guide.

Check If Service Is Running

Check If Service Is Running On Linux

Restart Service

Restart Service in Linux

Stop Service

Stop Service In Linux

Start Service

Start Service In Linux

List All Running Services

List All Running Services In Linux

Searching For Service Related Processes

A quick and easy way to do this is by using the ps command and piping it into a grep. To avoid false positives you can wrap the first letter of the service in brackets []. This will prevent your grep from showing up in the results.

Finding Processes For Services

Enabling/Disabling Services During Startup

To enable/disable a service during startup for example starting apache2 whenever the system reboots, you will use chkconfig command. In the example below I will set apache to start during boot. To disable a service on startup simply replace enable with disable. You can check if a service is enabled during startup by running chkconfig is-enabled servicename.

Enable/Disable Service On Startup

Thanks for reading, if you liked this post or if I forgot anything then please feel free to comment!

Leave a Reply

Your email address will not be published. Required fields are marked *