您的位置:首页 > 运维架构 > Linux

Linux启动关闭服务

2017-08-11 00:00 148 查看
摘要: Linux启动关闭服务

Linux启动关闭服务

linux启动关闭服务

RHEL7之前启动或关闭服务使用命令 service

service 服务名 start | stop | restart | status

这个命令在RHEL7中仍然支持,为了兼容之前的操作方式,RHEL7自动重定向到 systemctl命令



将服务设为开机启动

RHEL7之前将某一服务设为开机启动使用命令 chkconfig

chkconfig 服务名 on | off

chkconfig命令在RHEL7中仍然支持,但是会自动转发至systemctl命令

systemctl 命令

RHEL7使用命令systemctl启动或关闭服务

systemctl -l    #列出所有单元

在RHEL7中systemctl不仅仅用于服务的启动和关闭,还可以设置关于设备、挂在等等各种信息

systemctl status -type=service    #列出所有服务的启动情况




列出http这个服务的状态信息

systemctl status http    #列出http这个服务的状态信息




如果一个服务启动失败,可以在查看状态的最后添加-l选项,会显示启动失败信息,帮助做troubleshooting

systemctl status rngd.service -l




列出所有启动失败的服务信息

systemctl --failed --type=service




启动,关闭,重启服务

systemctl status sshd    #查看sshd服务启动情况
systemctl start sshd     #启动sshd服务
systemctl stop sshd     #关闭sshd服务

将服务设置为开机启动,设置服务开机关闭

systemctl enable sshd     #设置服务开机启动
systemctl disable sshd     #设置服务开机关闭
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息