RHCE7认证学习笔记8——控制服务和后台进程
1、控制服务(services and daemons)
RHEL7以前的版本控制服务使用service XX start|stop|status:
[root@linuxidc ~]# service sshd status
RHEL7控制服务使用systemctl start|stop|status|restart XX服务,查看服务的当前运行状态使用is-active:
[root@linuxidc ~]# systemctl status sshd
[root@linuxidc ~]# systemctl is-active sshd
active
[root@linuxidc ~]# systemctl sart|stop|restart sshd
查看某项服务是否会开机自动启动使用is-enable,相对应的是disable:
[root@linuxidc ~]# systemctl is-enabled sshd
enabled
禁用某项服务使用mask,相对应的是unmask:
下面总结一下systemctl命令常用控制服务的选项:
start [NAME...] Start (activate) one or more units 启动服务
stop [NAME...] Stop (deactivate) one or more units 停止服务
reload [NAME...] Reload one or more units 重新加载
restart [NAME...] Start or restart one or more units 重新启动
kill [NAME...] Send signal to processes of a unit 杀死进程
is-active [NAME...] Check whether units are active 是否启动
is-failed [NAME...] Check whether units are failed 是否失败
status [NAME...|PID...] Show runtime status of one or more units 状态
enable [NAME...] Enable one or more unit files 开机启动
disable [NAME...] Disable one or more unit files 开机不启动
reenable [NAME...] Reenable one or more unit files 重新设置开机启动
is-enabled [NAME...] Check whether unit files are enabled 是否开机启动
mask [NAME...] Mask one or more units 禁用服务
unmask [NAME...] Unmask one or more units 不禁用服务
查看系统所有服务:systemctl list-units-all或system ctl list-units-files:
[root@linuxidc ~]# systemctl list-units
[root@linuxidc ~]# systemctl list-unit-files
加上type选项可以查看所有服务:
[root@linuxidc ~]# systemctl list-unit-files --type service
UNIT FILE STATE
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-pstoreoops.service disabled
(责任编辑:IT) |