Linux常用服务类命令
服务类命令主要用于注册在系统中的标准化程序:
CentOS6主要使用service相关命令:
# 启动服务
service <服务名> start
# 停止服务
service <服务名> stop
# 重启服务
service <服务名> restart
# 重新加载服务
service <服务名> reload
# 查看服务状态
service <服务名> status
# 设置服务自启动
# 通过参数可以设置运行级别
chkconfig --level 5 <服务名> on
# 关闭服务自启动
chkconfig --level 5 <服务名> off
# 查看自启动的服务的列表
chkconfig --list
chkconfig --list | grep <服务名>
CentOS7主要使用service相关命令:
# 启动服务
systemctl start <服务名>
# 停止服务
systemctl stop <服务名>
# 重启服务
systemctl restart <服务名>
# 重新加载服务
systemctl reload <服务名>
# 查看服务状态
systemctl status <服务名>
# 设置服务自启动
# 通过参数可以设置运行级别
systemctl enable <服务名>
# 关闭服务自启动
systemctl disable <服务名>