[关闭]
@breakerthb 2016-07-13T06:28:18.000000Z 字数 1176 阅读 1340

Linux服务管理

Linux


Linux 服务管理

Service

CentOS 7之前的系统使用

1. 打印帮助

$ service <service>

打印指定服务的命令行使用帮助。

2. 启动服务

$ service <service> start

启动指定的系统服务

3. 停止服务

$ service <service> stop

停止指定的系统服务

4. 重启服务

$ service <service> restart

重新启动指定的系统服务,即先停止(stop),然后再启动(start)。

5. 查看服务列表

$ chkconfig --list

查看系统服务列表,以及每个服务的运行级别。

6. 设置开机自动启动

$ chkconfig <service> on

设置指定服务开机时自动启动。

## 7. 设置开机不自动启动

$ chkconfig <service> off

设置指定服务开机时不自动启动。

8. 全屏模式设置开机启动

$ ntsysv

以全屏幕文本界面设置服务开机时是否自动启动。

systemctl

CentOS 7 和 Ubuntu可用

systemctl命令将service和chkconfig命令结合在了一起。这样通过一个命令就可以实现两个命令的功能。

格式:

$ systemctl   动作   服务名.service

1. 查看帮助

$ systemctl --help

2. 启动服务

$ systemctl start httpd.service

3. 停止服务

$ systemctl stop httpd.service

4. 重启服务

$ systemctl restart httpd.service

5. 查看状态

$ systemctl status httpd.service

6. 开机启动

$ systemctl enable httpd.service

7. 取消开机启动

$ systemctl disable httpd.service

8. 系统操作

$ systemctl reboot 重启
	$ systemctl poweroff 关机
$ systemctl suspend 睡眠
	$ systemctl hibernate 休眠

9. 复杂操作

分析启动进程

$ 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

检查某个单元(如 smb.service)是否启用

$ systemctl is-enabled smb.service

ref:http://www.linuxdiyf.com/linux/13088.html

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注