您的位置:首页 > 其它

System V之我见

2013-10-21 13:19 246 查看
在查看很多系统性的文件和资料时,经常谈到system V, 有些是脚本。

比如:

service(8)                                                          service(8)

NAME
service - run a System V init script

SYNOPSIS
service SCRIPT COMMAND [OPTIONS]

service --status-all

service --help | -h | --version

DESCRIPTION
service  runs a System V init script in as predictable environment as possible, removing most environment variables and
with current working directory set to /.

The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT.  The supported values of  COMMAND
depend  on the invoked script, service passes COMMAND and OPTIONS it to the init script unmodified.  All scripts should
support at least the start and stop commands.  As a special case, if COMMAND  is  --full-restart,  the  script  is  run
twice, first with the stop command, then with the start command.

service --status-all runs all init scripts, in alphabetical order, with the status command.

FILES
/etc/init.d
The directory containing System V init scripts.

ENVIRONMENT
LANG, TERM
The only environment variables passed to the init scripts.

SEE ALSO
chkconfig(8), ntsysv(8)


一直纳闷什么是system V,其实都是Unix历史性的东东,感觉一段文字说的很好,system V都是有运行级别(run level),而BSD是没有的。

Linux下的service确实都是有运行级别的,系统本身也由runlevel,比如:

[root@localhost etc]# chkconfig
NetworkManager 	0:off	1:off	2:off	3:off	4:off	5:off	6:off
abrtd          	0:off	1:off	2:off	3:on	4:off	5:on	6:off
acpid          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
atd            	0:off	1:off	2:off	3:on	4:on	5:on	6:off
auditd         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
autofs         	0:off	1:off	2:off	3:on	4:on	5:on	6:off
avahi-daemon   	0:off	1:off	2:off	3:on	4:on	5:on	6:off
bluetooth      	0:off	1:off	2:off	3:on	4:on	5:on	6:off
certmonger     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
cgconfig       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
cgred          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
cpuspeed       	0:off	1:on	2:on	3:on	4:on	5:on	6:off
crond          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
cups           	0:off	1:off	2:on	3:on	4:on	5:on	6:off
dnsmasq        	0:off	1:off	2:off	3:off	4:off	5:off	6:off
dovecot        	0:off	1:off	2:off	3:off	4:off	5:off	6:off
firstboot      	0:off	1:off	2:off	3:off	4:off	5:off	6:off
haldaemon      	0:off	1:off	2:off	3:on	4:on	5:on	6:off
httpd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
ip6tables      	0:off	1:off	2:on	3:on	4:on	5:on	6:off
iptables       	0:off	1:off	2:off	3:off	4:off	5:off	6:off
irqbalance     	0:off	1:off	2:off	3:on	4:on	5:on	6:off
iscsi          	0:off	1:off	2:off	3:on	4:on	5:on	6:off
iscsid         	0:off	1:off	2:off	3:on	4:on	5:on	6:off
kdump          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
libvirt-guests 	0:off	1:off	2:off	3:on	4:on	5:on	6:off
libvirtd       	0:off	1:off	2:off	3:on	4:on	5:on	6:off
lvm2-monitor   	0:off	1:on	2:on	3:on	4:on	5:on	6:off
mdmonitor      	0:off	1:off	2:on	3:on	4:on	5:on	6:off
messagebus     	0:off	1:off	2:on	3:on	4:on	5:on	6:off
mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
netfs          	0:off	1:off	2:off	3:on	4:on	5:on	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
nfs            	0:off	1:off	2:off	3:off	4:off	5:off	6:off
nfslock        	0:off	1:off	2:off	3:on	4:on	5:on	6:off
nscd           	0:off	1:off	2:off	3:off	4:off	5:off	6:off
nslcd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
ntpd           	0:off	1:off	2:off	3:off	4:off	5:off	6:off
ntpdate        	0:off	1:off	2:off	3:off	4:off	5:off	6:off
oddjobd        	0:off	1:off	2:off	3:off	4:off	5:off	6:off
portreserve    	0:off	1:off	2:on	3:on	4:on	5:on	6:off
postfix        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
psacct         	0:off	1:off	2:off	3:off	4:off	5:off	6:off
qpidd          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
rdisc          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
restorecond    	0:off	1:off	2:off	3:off	4:off	5:off	6:off
rhnsd          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
rpcbind        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
rpcgssd        	0:off	1:off	2:off	3:on	4:on	5:on	6:off
rpcidmapd      	0:off	1:off	2:off	3:on	4:on	5:on	6:off
rpcsvcgssd     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
rsyslog        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
saslauthd      	0:off	1:off	2:off	3:off	4:off	5:off	6:off
smartd         	0:off	1:off	2:off	3:off	4:off	5:off	6:off
snmpd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
snmptrapd      	0:off	1:off	2:off	3:off	4:off	5:off	6:off
spamassassin   	0:off	1:off	2:off	3:off	4:off	5:off	6:off
sshd           	0:off	1:off	2:on	3:on	4:on	5:on	6:off
sssd           	0:off	1:off	2:off	3:off	4:off	5:off	6:off
sysstat        	0:off	1:on	2:on	3:on	4:on	5:on	6:off
tgtd           	0:off	1:off	2:off	3:off	4:off	5:off	6:off
tomcat6        	0:off	1:off	2:off	3:off	4:off	5:off	6:off
udev-post      	0:off	1:on	2:on	3:on	4:on	5:on	6:off
vncserver      	0:off	1:off	2:on	3:on	4:on	5:on	6:off
vsftpd         	0:off	1:off	2:off	3:off	4:off	5:off	6:off
wpa_supplicant 	0:off	1:off	2:off	3:off	4:off	5:off	6:off
xinetd         	0:off	1:off	2:off	3:on	4:on	5:on	6:off
ypbind         	0:off	1:off	2:off	3:off	4:off	5:off	6:off

xinetd based services:
amanda:        	off
chargen-dgram: 	off
chargen-stream:	off
cvs:           	off
daytime-dgram: 	off
daytime-stream:	off
discard-dgram: 	off
discard-stream:	off
echo-dgram:    	off
echo-stream:   	off
rsync:         	off
tcpmux-server: 	off
telnet:        	on
time-dgram:    	off
time-stream:   	off
[root@localhost etc]#


Linux系统下的runlevel定义在/etc/inittab, 如:

[root@localhost etc]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used 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:
[root@localhost etc]#


相对应的,BSD类系统则没有,比如Mac

mingjuwus-MacBook-Pro:etc mingjuwu$ which chkconfig
mingjuwus-MacBook-Pro:etc mingjuwu$ ls /etc/inittab
ls: /etc/inittab: No such file or directory
mingjuwus-MacBook-Pro:etc mingjuwu$ which service
mingjuwus-MacBook-Pro:etc mingjuwu$


个人认为,Linux本身就是System V的OS。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: