Linux リテラシ2006 - 第6回 デーモン

javelin


demon()daemon()




OS


(一)Enter

(二)OS

(三)

(四)

$ ps [オプション...]






a



u



x









$ ps aux
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  3216  560 ?        S    Jun05   0:00 init [3]
root         2  0.0  0.0     0    0 ?        S    Jun05   0:00 [migration/0]
root         3  0.0  0.0     0    0 ?        SN   Jun05   0:00 [ksoftirqd/0]
root         4  0.0  0.0     0    0 ?        S    Jun05   0:00 [migration/1]
root         5  0.0  0.0     0    0 ?        SN   Jun05   0:00 [ksoftirqd/1]
root         6  0.0  0.0     0    0 ?        S<   Jun05   0:00 [events/0]
…中略…
root      3494  0.0  0.2  9396 2252 ?        SNs  Jun05   0:00 cupsd
root      5818  0.0  0.0     0    0 ?        S<   Jun05   0:00 [krfcommd]
root      5849  0.0  0.0  3336  876 ?        Ss   Jun05   0:00 hcid: processing events
root      5853  0.0  0.0  2548  528 ?        Ss   Jun05   0:00 sdpd
httpd    13781  0.0  0.1  4708 1848 ?        S    Jun07   0:00 /usr/local/httpd/bin/httpd 
foo    24160  0.0  0.0  3284  744 pts/0    R+   09:12   0:00 ps aux

USERPIDIDIDSTATCOMMAND
ps aux


使4
種類 用途
INT(INTerrupt) 現在ユーザが実行しているプロセスに対して割り込みをかけます。端末上でCtrl+cと入力するとこの効果を得ます。
TERM(TERMinate) 終了させるという意味どおり、プロセスを終了させるために使います。
HUP(HangUP) デーモンなどの設定ファイルなどについては再読み込みをすることもあります。
KILL(KILL) INTやTERMでは終了できないような(暴走している)プロセスを強制的に終了させるために使われます。

使kill
$ kill [オプション] シグナル プロセスID



-s




使




ID1234

$ kill -s TERM 1234


使
ln [オプション] リンク元 リンクの置き場所



-s





hogebar

$ ln -s hoge bar

ls-l
$ ls -l
-rw-rw-r--  3 foo   foo        50  5月  1 21:21 hoge
lrwxrwxrwx  1 foo   foo         4  6月 19 10:52 bar -> hoge

l-> hogehoge


lni使3Windows
/etc/rc.d/init.d/
/etc/rc.d/init.d/
$ ls /etc/rc.d/init.d
FreeWnn         crond               httpd       messagebus     pcmcia           sendmail
NetworkManager  cups                iiim        microcode_ctl  portmap          single
acpid           cups-config-daemon  ipmi        netdump        psacct           smartd
anacron         diskdump            iptables    netfs          rawdevices       sshd
apmd            dund                irda        netplugd       readahead        syslog
atd             firstboot           irqbalance  network        readahead_early  vncserver
auditd          functions           isdn        nfs            rhnsd            winbind
autofs          gpm                 killall     nfslock        rpcgssd          xfs
bluetooth       haldaemon           kudzu       nscd           rpcidmapd        xinetd
canna           halt                mdmonitor   ntpd           rpcsvcgssd       ypbind
cpuspeed        hidd                mdmpd       pand           saslauthd        yum


$ ls -l /etc/rc.d/
drwxr-xr-x  2 root root  4096  6月 16 05:43 init.d

4096
$ ln -s /etc/rc.d/init.d/ init

/etc/rc.d/init.dinit
$ cd init

init
$ ls
FreeWnn         crond               httpd       messagebus     pcmcia           sendmail
NetworkManager  cups                iiim        microcode_ctl  portmap          single
acpid           cups-config-daemon  ipmi        netdump        psacct           smartd
anacron         diskdump            iptables    netfs          rawdevices       sshd
apmd            dund                irda        netplugd       readahead        syslog
atd             firstboot           irqbalance  network        readahead_early  vncserver
auditd          functions           isdn        nfs            rhnsd            winbind
autofs          gpm                 killall     nfslock        rpcgssd          xfs
bluetooth       haldaemon           kudzu       nscd           rpcidmapd        xinetd
canna           halt                mdmonitor   ntpd           rpcsvcgssd       ypbind
cpuspeed        hidd                mdmpd       pand           saslauthd        yum

/etc/rc.d/init.d/
$ pwd
/home/foo/init

/etc/rc.d/init.d/init
$ ls -l
lrwxrwxrwx  1 foo      foo        17  6月 21 00:36 init -> /etc/rc.d/init.d/

17


Linux06/etc/inittab
# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

id:5:initdefault:5
使1,3,5CentOSFedoraCoreRedHat
ランレベル用途
0 コンピュータの電源を切る
1 障害復旧用
2 CUIのみを使用する状態でネットワークをつながない場合
3     CUIのみを使用する場合
4 使用されてません
5 GUI環境を使用する場合
6 再起動する場合

/etc/rc?.d/ls
?




5

[foo@cisnote ~]$ ls /etc/rc5.d
K-1ipmi                K30spamassassin  K85mdmpd            S09pcmcia
K01yum                 K35vncserver     K86nfslock          S10network
K02NetworkManager      K35winbind       K87auditd           S12syslog
K02cups-config-daemon  K36lisa          K87irqbalance       S26apmd
K02haldaemon           K40smartd        K87portmap          S28autofs
K03messagebus          K44rawdevices    K89netplugd         S44acpid
K03rhnsd               K50netdump       K90bluetooth        S55sshd
K05anacron             K50xinetd        K91isdn             S85gpm
K05atd                 K68rpcidmapd     K94diskdump         S87iiim
K05saslauthd           K69rpcgssd       K96ipmi             S90canna
K10cups                K73ypbind        K99microcode_ctl    S90crond
K10psacct              K74lm_sensors    K99readahead        S90xfs
K12FreeWnn             K74nscd          K99readahead_early  S99local
K20nfs                 K74ntpd          S05kudzu
K24irda                K75netfs         S06cpuspeed
K30sendmail            K85mdmonitor     S08iptables

K-1ipmiS05kudzu1KS


WEB使GUI


ntsysvWindows
# ntsysv [オプション]



--level 06




rootsu -root使




ntsysv5

ntsysv --level 5


55


/etc/init.d/
# /etc/init.d/サービス名 起動オプション



start



stop



restart





network

# /etc/init.d/network restart

networkLinux



crond



crondcrond

sshd


5sshssh
422sshsshd


GUICUIshutdown
# shutdown オプション 時間

オプション

-h
電源を切る
-r
再起動する

時間

now
今すぐ実行する

今すぐ電源を切る

shutdown -h now