Chapter 9. Step 9: Starting and Stopping

If you are investigating a system that seems hung (perhaps the public website isn’t responding and your management wants you to “do something”), the old tried-and-true method of restarting services or the entire system itself is often your last resort. Rebooting Windows always fixes problems, so you already know one method for approaching Linux issues too! In this chapter, I show you how to restart services and reboot the system.

Most commands in this report will not alter system state. However, this chapter covers commands that start, stop, and restart Linux services and the entire system. Therefore, you could possibly stop something, and because of the situation you are investigating, not be able to restart it. So be careful!

Managing Services

Linux services (a.k.a. daemons, which is why so many Linux services end in d, such as sshd and httpd) are similar to Windows services. They are processes that run in the background, typically initiated at system startup. Examples of services include web services (Apache), database services (MySQL), and so on.

Typically, you use the service command to start, stop, and restart services. It requires sudo. Figure 9-1 shows how to start the mysql service.

service start command
Figure 9-1. service start command

You can see that the process ID (PID) of the service is returned by the command. You stop a service the same way, ...

Get Ten Steps to Linux Survival now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.