linux服務deamon 1、分兩類:stand alone,super daemon(由xinetd這個deamon來負責) www.2cto.com 2、相關目錄:/etc/init.d/* :啟動指令碼放置處/etc/sysconfig/* :各服務的初始化環境設定檔/etc/xinetd.conf, /etc/xinetd.d/* :super daemon 設定檔/etc/* :各服務各自的設定檔/var/lib/* :各服務產生的資料庫/var/run/* :各服務的程式之 PID 記錄處/etc/services:設定連接埠號碼 3、stand alone啟動方式:service httpd start或/etc/init.d/httpd start www.2cto.com 4、super daemon啟動方式:查詢是否啟動:grep -i 'disable' /etc/xinetd.d/*如果顯示/etc/xinetd.d/rsync: disable = yes則是沒有啟動的,如果要啟動,如啟動rsync,則vim /etc/xinetd.d/rsync找到disable = yes改為no,再重啟服務 /etc/init.d/xinetd restart 或直接chkconfig rsync on ,再重啟xinetd 5、super daemon設定檔/etc/xinetd.d/下及/etc/init.d/xinetd 下,各參數說明見其他文檔 6、xinetd 管理的服務“防火牆”/etc/hosts.allow, /etc/hosts.deny 基本上只要一個服務受到 xinetd 管理,或者是該服務的程式支援 TCP Wrappers 函式的功能時,那麼該服務的防火牆方面的設定就能夠以 /etc/hosts.{allow,deny} 來處理囉。換個方式來說,只要不支援 TCP Wrappers 函式功能的軟體程式就無法使用 /etc/hosts.{allow,deny} 的設定值。 判斷有沒有CP Wrappers 函式的功能的方法:[root@www ~]# ldd $(which sshd httpd)/usr/sbin/sshd: libwrap.so.0 => /usr/lib64/libwrap.so.0 (0x00002abcbfaed000) libpam.so.0 => /lib64/libpam.so.0 (0x00002abcbfcf6000)....(中間省略)..../usr/sbin/httpd: libm.so.6 => /lib64/libm.so.6 (0x00002ad395843000) libpcre.so.0 => /lib64/libpcre.so.0 (0x00002ad395ac6000)....(底下省略)....# 重點在於軟體有沒有支援 libwrap.so 那個函式庫囉,有的話就是有這個功能。 7、/etc/hosts.allow, /etc/hosts.deny 格式[root@www ~]# vim /etc/hosts.denyrsync : 127.0.0.100 127.0.0.200 : deny 或 [root@www ~]# vim /etc/hosts.denyrsync : 127.0.0.100 : denyrsync : 127.0.0.200 : deny /etc/hosts.allow 的設定優先於 /etc/hosts.deny,如果兩個檔案都沒有,則表示不經過此防火牆,即接受。 ALL:代表全部的 program_name 或者是 IP 都接受的意思,例如 ALL: ALL: deny LOCAL:代表來自原生意思,例如: ALL: LOCAL: allow UNKNOWN:代表不知道的 IP 或者是 domain 或者是服務時; KNOWN:代表為可解析的 IP, domain 等等資訊時。 如:[root@www ~]# vim /etc/hosts.denyrsync: ALL 8、TCP Wrappers 特殊功能:當有其他人掃瞄我的 rsync port 時,我就將他的 IP 記住,以做為未來的查詢與認證之用需要安裝了 TCP Wrappers 軟體才行。要確定有沒有安裝 TCP Wrappers 可以使用‘ rpm -q tcp_wrappers ’來查詢。具體用法見其他資料。 9、查看系統啟動哪些服務:netstat -tanlp查看所有服務狀態:service --status-all查看開機啟動服務:chkconfig --list |more開啟開機啟動服務:chkconfig deamon_name on 10、把自己的服務放入chkconfig來管理:chkconfig [--add|--del] [服務名稱]a、自建的服務要放入/etc/init.d/b、服務指令碼的內容要寫上:# chkconfig: 35 80 70c、chkconfig --add 服務名