456
◾
Linux with Operating System Concepts
What we see in Figure 11.2 are 22 stopped services and 37 started services. For instance,
httpd is killed because this service by default is not needed (this is the Apache web server
and most Linux users will not be running a web server). Similarly, smartd, a service to
monitor the reliability of your hard disk drive(s) is stopped because,
unless there is a reason
to suspect drive failures, this service would be resource-heavy and somewhat irrelevant.
On the other hand, we see the Linux firewall (iptables, ip6tables), the ssh daemon, the nfs
daemon, the cron and at daemons, and the printer service (cups) are all started as these are
commonly used network or multiuser services.
You can modify which services are automatically started and stopped by changing
the symbolic links under the appropriate rc#.d
directory, altering the K and S labels. For
instance, if you wanted httpd to start under runlevel 5, then under /etc/rc5.d, change
K15httpd to S85httpd (we explore later where we can find the two-digit values 15 and 85).
Alternatively, there is a program called
chkconfig
. Without options, it displays for
each service, which runlevels it is started and stopped for. For instance, the sshd service
contains the following entry:
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
You can alter any service’s
behavior using
chkconfig --level
levelnumber servicename status
where
levelnumber
is the runlevel,
servicename
is the name of the service, and
status
is on
or off.
11.4.4 Finalizing System Initialization
Now that services are started, Linux is ready for use. The script /
etc/rc.d/rc.local
is the last script executed. This script is available for system administrators to perform
additional automated startup operations. If you, as a system administrator, wish to have
some external file system mounted and
made available for all users, you could include the
FIGURE 11.2
Symbolic links to services for runlevel 5.
System Initialization and Services
◾
457
mount command in this script. If you want to have scheduled processes run, you could add
scheduling commands to this script.
Other scripts may be started by Upstart prior to the rc scripts. Again, these are found
in /etc/init and include scripts to define actions for ctrl
+
alt
+
del (control-alt-delete.conf),
scripts to start terminal windows (start-ttys.conf, tty.conf), and scripts to start up a GUI
display manager (prefdm.conf).
As a system administrator, you are able to adjust the operating system initialization
process by adjusting some of these start-up scripts (although there would probably be little
need to do so). Any such changes should be done cautiously
with the current version of
the scripts saved under different names so that you can roll the system back as necessary.
You can also explore the kernel initialization process. After the system has been brought
up, the command
dmesg
will respond with the kernel ring buffer. These are the messages
that the kernel produces when initializing. Although much of the information that dmesg
will display is cryptic, you can examine it for possible boot errors (as well as to learn more
about the Linux boot process).
11.5
LINUX SERVICES
In this section, we briefly explore the various services in Linux. In Linux, a service is gener-
ally referred to as a daemon (pronounced “demon”). We will consider several services in
more detail in the next two sections when we look at how those services can be configured.
These sections are incomplete as there are far too many services to cover.
A service is a piece of operating system code used to handle some type of request. The
service has several distinctive features. First, it runs in the background so that it does not
take up processor time unless called upon. Second, services can handle requests that come
from many different sources: users,
applications software, hardware, other operating sys-
tem services, messages from the network. Third, services are
Do'stlaringiz bilan baham: