背景:
操作系统:
# uname -a
Linux localhost 3.11.10-7-desktop #1 SMP PREEMPT Mon Feb 3 09:41:24 UTC 2014 (750023e) x86_64 x86_64 x86_64 GNU/Linux
以下将Linux命令chkconfig在本机openSuse Linux下的联机帮助文档进行翻译并举例加以说明其用法,让我们来拭目以待吧。
说明:以下英文行大家英文不好的话,可以只看我的中文部分。中文部分,是我尽兴翻译的,中文部分没有完全依照英文进行翻译。
chkconfig 命令的功能是使操作系统提供的服务进行激活或者失效即所谓的启动与关闭。
chkconfig - enable or disable system services
语法如下:
SYNOPSIS
chkconfig -t|--terse [names] (shows the links)
chkconfig -s|--set [name state]
chkconfig -e|--edit [names]
chkconfig -c|--check name [state]
chkconfig -l|--list [--deps] [names]
chkconfig -A|--allservices
chkconfig -a|--add [names]
chkconfig -d|--del [names]
以上就是chkconfig命令的具体语法格式,大家是不是一看就蒙了,没关系,我们举几个例子来说明一下吧!
我们直接输入 chkconfig命令, OS会将当前系统之中提供的服务与状态一一列出,结果如下:
# chkconfig
after.local off
alsasound on
amavis off
apache2 off
autofs off
avahi-daemon on
avahi-dnsconfd off
before.local off
bgpd off
chargen off
以上部分截取,省略了很多部分哦。
以上执行命令输出的结果太多了,看着是不是太麻烦啊,我知道系统之中有一个叫cron的服务,直接了当,就查看它的状态了,这时我们只要
直接将服务名加在chkconfig命令后,就可以了。
#chkconfig cron
cron cron on
看到没,系统的cron服务正在运行,让我们来吧它提供的服务关闭吧,跟我来,
#chkconfig cron off
# chkconfig cron
cron off
怎么样,cron服务停止了吧,怎么能让他停止呢,停止以后,你的调度任务可就**,停止工作了,还是把它启动起来吧。
#chkconfig cron on
# chkconfig cron
cron on
是不是很简单啊,下面来个复杂一点的,如果我要一起修改2个服务状态呢,哈哈,
跟我来, 我要将autofs, cron 都停止,看看复杂了没:
chkconfig autofs off cron off
简单吧,更多个服务只要依次往下写就可以了,前提是不要写错哦。
关闭怎么能行呢,还是恢复原样吧。
#chkconfig autofs on cron on
我们系统那么多的服务需要管理,让我们来对系统提供的服务进行一下备份吧。
#chkconfig >~root/chkconfig.save
哈哈,备份文件备份好了,让我们看看文件的内容吧。
# cat ~root/chkconfig.save
after.local off
alsasound on
amavis off
apache2 on
autofs on
avahi-daemon on
avahi-dnsconfd off
before.local off
bgpd off
chargen off
chargen-udp off
cifs off
clamav-milter off
clamd off
cron on
cups on
cups-lpd off
cvs off
cyrus off
daytime off
daytime-udp off
dbus on
discard off
discard-udp off
dkms_autoinstaller on
echo off
echo-udp off
esound off
fetchmail off
freshclam off
gpm off
icecream off
inn off
inputattach off
irq_balancer off
joystick off
kexec off
lirc off
lm_sensors off
mailman off
mcelog off
mdadmd off
mysql off
nagios off
netstat off
network on
nfs off
nfsserver off
ntp off
ospf6d off
ospfd off
pcscd on
pm-profiler off
postfix on
powerd off
raw off
ripd off
ripngd off
rpmconfigcheck off
rsync off
rsyncd off
sane-port off
servers off
services off
smpppd off
snmpd off
snmptrapd off
spamd off
spampd off
sshd off
svnserve off
systat off
tftp on
time off
time-udp off
vboxautostart-service on
vboxballoonctrl-service on
vboxdrv on
vboxweb-service on
vmamqpd on
vmware on
vmware-USBArbitrator on
vnc off
vnchttpd off
vsftpd off
xdm on
ypbind off
zebra off
怎么样,这个方法进行备份不错吧,如果有一天发现服务设置的不对了,可以用之前的备份进行恢复,只需要执行一下这个命令,
chkconfig -s <~root/chkconfig.save
时间过的真快,转眼间八点多了,该回家了,下面的部分暂时先放放,明天继续完成,大家如果英语没有障碍的话,可以先看看,如果懒得看英文,喜欢我的这种风格的话,就请多多关注吧。
以下部分暂时没有翻译,见谅。
DESCRIPTION
chkconfig is used to manipulate the runlevel links at boot time (see init.d(7)). It can be thought of
as a frontend to insserv(8). Chkconfig can run in six different modes: terse list mode, set mode, edit
mode, list mode, add mode and delete mode. The last three modes were added for compatiblity reasons.
TERSE LIST MODE
This mode lists the state of the specified services, or all known services if no service name was pro-
vided. Every printed line consists of the name of the service and the runlevels the service is config-
ured for at the moment. If it is configured in no runlevel, off is used instead, if it is configured in
the runlevels defined as a default by the start script, on is used. If the service is an enabled inetd
or xinetd service, inetd and xinetd are used. Inetd/xinetd services are configured in /etc/inetd.d and
/etc/xinetd.d, respectively. You can use the -A or --allservices parameter to get all services (even
the boot.*-services) listed.
If chkconfig is called without arguments, all services are listed in terse mode.
SET MODE
Set mode is used to configure at which runlevel a service should be started. The arguments must be
specified as pairs of service name and new state. You can use on and off as special states to select
the default set of runlevels or to disable a service completely. You can use inetd or xinetd to config-
ure a service managed by the inetd/xinetd daemons.
Insserv can calculate dependencies for only one service at the same time. To work around this limita-
tion imposed by insserv, chkconfig uses the '-f' option of insserv when it reads the list of services
from standard input. Note that --force switches off all dependency checks and could lead to depending
services no longer working, use with care.
If no services are specified, chkconfig reads lines from standard input. Each line must consist of a
service/state pair. As this is exactly the output of the terse list mode, this can be used to reconfig-
ure a service specification saved by a former run.
If the option -f or --force is also given, insserv is called with a '-f' option.
EDIT MODE
This mode is a combination of the terse list mode and set mode. It writes the state of all specified
services (or all known services, if no service was provided) into a temporary file, starts an editor
and re-configures all services to reflect the states of the changed temporary file.
CHECK MODE
This mode can be used to check the state of a service. chkconfig exits with a return code of '0' if
the service is enabled in all of the specified runlevels, otherwise the exit status is '1'. If chkcon-
fig is called with only a service name the current runlevel of the system is used for checking.
LIST MODE
List mode prints for each specified service a line that consists of the service name and for runlevels
zero to six on or off depending if the service will be started or not. on will be printed in bright
green if the output is written to a terminal. If the --deps option is given, the names of the services
that must be started before this service is appended to each line. The inetd/xinetd services are listed
in extra sections.
You can use the -A or --allservices parameter to get all services (even the boot.*-services) listed.
ADD MODE
Calls insserv to enable a service and uses list mode to display the new setting afterwards.
DEL MODE
Same as add mode, but disable the service.
OTHER OPTIONS
When no service names are given on the command line, chkconfig defaults to all known services excluding
those that are not enabled in runlevels 1 to 6 and start with 'boot.'. Use the --allservices or -A
option if you want to see such services as well.
FILES
/etc/init.d/
path to the boot script base directory as required by the Linux Standard Base Specification
(LSB).
/etc/inetd.d/
path to the inetd services. See the inetd manpage to find out how to enable this feature.
/etc/xinetd.d/
path to the xinetd services.
SEE ALSO
init.d(7), init(7), inetd(8) xinetd(8) insserv(8)
COPYRIGHT
2003 SuSE Linux AG, Nuernberg, Germany.
AUTHOR
Michael Schroeder
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23628945/viewspace-1130204/
,如需转载,请注明出处,否则将追究法律责任。