查看系统服务:
[root@linux ~]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
系统显示了netconsole和network两个服务,对应的值表示各个运行级别下的服务开关状态,如果是开,该服务将开机启动,服务脚本路径在/etc/init.d/下:
[root@linux ~]# ls /etc/init.d/
functions netconsole network README
运行级别: runlevel命令查看
0:表示关机状态
1:表示单用户模式
2:表示多用户模式(与3级别相比没有NFS服务)
3:多用户模式
4:未使用,系统保留
5:图形界面的多用户模式
6:表示重启
开启服务:
[root@linux ~]# chkconfig network on
关闭服务:
[root@linux ~]# chkconfig network off
指定运行级别下关闭或开启操作:
[root@linux ~]# chkconfig --level 345 network off
[root@linux ~]# chkconfig --list
network 0:关 1:关 2:开 3:关 4:关 5:关 6:关
–level :指定操作的运行级别,示例中指定3,4,5级别下关闭
添加自定义脚本到chkconfig管理:
1.先将脚本放入目录 /etc/init.d/中
[root@linux ~]# cp /etc/init.d/network /etc/init.d/test
[root@linux ~]# ls /etc/init.d/
functions netconsole network README test
2.添加服务:
[root@linux ~]# chkconfig --add test
[root@linux ~]# chkconfig --list
test 0:关 1:关 2:开 3:开 4:开 5:开 6:关
3.删除服务:
[root@linux ~]# chkconfig --del test