@breakerthb
2016-07-13T06:28:18.000000Z
字数 1176
阅读 1433
Linux
Linux 服务管理
CentOS 7之前的系统使用
$ service <service>
打印指定服务的命令行使用帮助。
$ service <service> start
启动指定的系统服务
$ service <service> stop
停止指定的系统服务
$ service <service> restart
重新启动指定的系统服务,即先停止(stop),然后再启动(start)。
$ chkconfig --list
查看系统服务列表,以及每个服务的运行级别。
$ chkconfig <service> on
设置指定服务开机时自动启动。
## 7. 设置开机不自动启动
$ chkconfig <service> off
设置指定服务开机时不自动启动。
$ ntsysv
以全屏幕文本界面设置服务开机时是否自动启动。
CentOS 7 和 Ubuntu可用
systemctl命令将service和chkconfig命令结合在了一起。这样通过一个命令就可以实现两个命令的功能。
格式:
$ systemctl 动作 服务名.service
$ systemctl --help
$ systemctl start httpd.service
$ systemctl stop httpd.service
$ systemctl restart httpd.service
$ systemctl status httpd.service
$ systemctl enable httpd.service
$ systemctl disable httpd.service
$ systemctl reboot 重启
$ systemctl poweroff 关机
$ systemctl suspend 睡眠
$ systemctl hibernate 休眠
$ systemd-analyze
$ systemd-analyze blame
$ systemd-analyze critical-chain
$ systemctl list-unit-files
$ systemctl list-unit-files | grep smb
$ systemctl list-units
$ systemctl list-units | grep smb
$ systemctl --failed
$ systemctl is-enabled smb.service