Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet172/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   168   169   170   171   172   173   174   175   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

name
is the service 
name.
K
##name
or
S
##name
The K or S is used to indicate whether the particular service should be stopped (killed) 
or started, respectively. The 
##
are two digits that indicate the order that the services 
should be stopped or started. The order is controlled by globbing when K* or S* is file-
name expanded. Since all of the services to be killed will be listed by K*, the filenames are 
expanded based on the two-digit number rather than the name that follows. Otherwise, 
services would be killed in alphabetical order.
The first for loop iterates through all of the 
K
##name
services, stopping them in the 
order that the services are numbered. The second for loop iterates through all of the 
S
##name
services, starting them in the order that the services are numbered.
You might ask why services need to be stopped if you are just now initializing the sys-
tem. The 
telinit
instruction allows you to change runlevels from the command line. So, 
if you are currently in runlevel 5 and wish to switch to runlevel 1, 
telinit 1
will accom-
plish this. However, in switching from 5 to 1, you must kill any service that is started by 
runlevel 5 but which should not be running for runlevel 1. Similarly, exiting from runlevel 
1 back to runlevel 5 will require restarting those services.
Figure 11.2 shows the contents of the rc5.d subdirectory. Recall that runlevel 5 is mul-
tiuser, networked, and GUI. Thus, we would expect services that deal with multiple users, 
the network, and the GUI to all be started. Other services that are not needed by this 
runlevel are stopped. The system administrator can decide whether any unstarted services 
should be started at a later time.


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 

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   168   169   170   171   172   173   174   175   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish