3.3.6 Starting and Stopping Services

To start a service, either run its /etc/init.d script directly with the start argument, for example:

# /etc/init.d/sshd start
Starting sshd:                                             [  OK  ]

or use the service command with the start argument:

# service sshd start
Starting sshd:                                             [  OK  ]

Similarly, to stop a service, use the stop argument:

# service sshd stop
Stopping sshd:                                             [  OK  ]
Note

Changing the state of a service only lasts as long as the system remains at the same run level. If you stop a service and then change the system's run state to one in which the service is configured to run (for example, by rebooting the system), the service restarts.

Some scripts take other arguments, such as restart, reload, and status. Omitting an argument displays a usage message:

# service sshd
Usage: /etc/init.d/sshd {start|stop|restart|reload|force-reload|condrestart|try-restart|status}

If supported, you can use the status argument to view the status of a service:

# service sshd status
openssh-daemon (pid  12101) is running...         

For more information, see the service(8) manual page.