service failure.
Starting and Stopping Services Manually
If you change a configuration file for a system service, it is usually necessary
to stop and restart the service to make it read the new configuration. If you are
reconfiguring the X server, it is often convenient to change from runlevel 5 to
runlevel 1 to make testing easier and then switch back to runlevel 5 to
reenable the graphical login. If a service is improperly configured, it is easier
to stop and restart it until you have it configured correctly than it is to reboot
the entire machine.
The traditional way to manage a service (as root) is to call the service’s
/etc/init.d name on the command line with an appropriate keyword,
such as start, status, restart, or stop. For example, to start the
Apache web server, call the /etc/init.d/apache2 script like this:
Click here to view code image
matthew@seymour:~$ sudo /etc/init.d/apache2 start
Starting apache 2.2 web server [
OK ]
The script executes the proper program(s) and reports the status of the
program(s). Stopping services is equally easy, using the stop keyword.
Using Upstart
Starting in 2015, Ubuntu switched to using systemd instead of Upstart. This
content is being retained in the book for users of LTS versions like 14.04 LTS
that are still supported, but for anyone doing a new installation, you should
skip this section and move immediately to the next section, “Using
systemd.” If you are upgrading from an earlier release of Ubuntu, you may
benefit from reading https://wiki.ubuntu.com/SystemdForUpstartUsers.
Upstart was originally developed for Ubuntu. It is an event-based replacement
for the /sbin/init daemon and System-V init system. It handles starting
of tasks and services during boot and stops them during shutdown. It also
supervises them while the system is running and is intended to become a way
to have tasks and services start or stop automatically, based on specific events
that happen, rather than having to call a script manually to start or stop them.
This is a big change and a big deal because it makes the overall system much
more flexible, configurable, and responsive to conditions.