linux命令修改网络 linux更改网络( 二 )


--add增加所指定的系统服务,让 chkconfig 指令得以管理它,并同时在系统启动的叙述文件内增加相关数据 。
--del删除所指定的系统服务,不再由 chkconfig 指令管理,并同时在系统启动的叙述文件内删除相关数据 。
--level等级代号指定读系统服务要在哪一个执行等级中开启或关毕 。
实例
列出chkconfig 所知道的所有命令,可以用chkconfig –list查看所有的服务及其在每个级别的开启状态 。
# chkconfig --list
开启服务
# chkconfig telnet on//开启 Telnet 服务
# chkconfig --list//列出 chkconfig 所知道的所有的服务的情况
关闭服务
# chkconfig telnet off// 关闭 Telnet 服务
# chkconfig --list// 列出 chkconfig 所知道的所有的服务的情况
[root@cent01 sbin]# chkconfig --level 3 network off//关闭3级别的network服务
[root@cent01 sbin]# chkconfig --list //3级别已关闭
network0:关 1:关 2:开 3:关 4:开 5:开 6:关
[root@cent01 sbin]# chkconfig network on //不输入级别,默认打开2,3,4,5级别
[root@cent01 sbin]# chkconfig --list
network0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@cent01 sbin]# chkconfig --del network //删除network
[root@cent01 sbin]# chkconfig --list//network已消失
mysqld0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole0:关 1:关 2:关 3:关 4:关 5:关 6:关
[root@cent01 sbin]# chkconfig --add network //增加network服务
[root@cent01 sbin]# chkconfig --list//network服务又恢复了
mysqld0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole0:关 1:关 2:关 3:关 4:关 5:关 6:关
network0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@cent01 sbin]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务 。SysV 配置数据
可能被原生 systemd 配置覆盖 。
要列出 systemd 服务,请执行 'systemctl list-unit-files' 。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]' 。
mysqld0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole0:关 1:关 2:关 3:关 4:关 5:关 6:关
注意: 但是这里只显示了SysV管理的服务,centos6及之前都是这个管理工具,但是在centos7用的是systemd管理,所以systemd管理的服务在这里没有显示出来 。
运行级别为系统启动级别,具体含义如下:
0 shutdown关机
1 单用户模式
2 无NFS支持的多用户模式
3 完全多用户模式,常用的命令行模式
4 保留给用户自定义
5 图形界面登录,比3多了一个图形界面
6 重启
1.3.2、Linux systemd命令
systemd是管理开机启动程序的工具(SysV启动开机进程时一次只能启动一个,而systemd则一次可以启动多个服务,这样就导致systemd的开机速度会更快 。)
[root@localhost ~]# systemctl list-units --all --type=service
UNITLOADACTIVESUBDESCRIPTION
abrt-ccpp.serviceloadedactiveexitedInstall ABRT coredump hook
abrt-oops.serviceloadedactiverunning ABRT kernel log watcher
UNITLOADACTIVESUBDESCRIPTION
[root@cent01 sbin]# ls /usr/lib/systemd/system//启动的脚本文件目录
[root@cent01 ~]# systemctl list-units//列出正在运行的unit
[root@cent01 ~]# systemctl list-units --all //列出所有的unit , 包括active和inactive
[root@cent01 ~]# systemctl list-units --all --state=inactive //列出inactive的unit
[root@cent01 ~]# systemctl list-units --all --type=service//列出所有状态的service
[root@cent01 ~]# systemctl list-units --type=service//列出active的service
[root@cent01 ~]# systemctl is-active crond.service//查看某个unit是否active
systemctl enable crond.service //开机启动 .service可以省略

推荐阅读