linux服务开机启动chkconfig
时间: 2023-08-28 18:08:04 浏览: 64
chkconfig是Linux系统中的一个命令行工具,用于管理系统服务的启动和停止。chkconfig被用来管理运行级别(runlevel) 2-5 的系统服务,它可以让你在系统启动时自动启动一些服务,或者在系统关闭时自动关闭一些服务。
以下是chkconfig的常用命令:
1. 列出所有的服务及其当前运行级别
```
chkconfig --list
```
2. 列出指定服务的运行级别
```
chkconfig --list <服务名>
```
3. 启动指定服务并设置为开机启动
```
chkconfig <服务名> on
```
4. 停止指定服务并设置为不开机启动
```
chkconfig <服务名> off
```
5. 设置指定服务在某个运行级别下启动或停止
```
chkconfig --level <运行级别> <服务名> on/off
```
6. 检查指定服务是否已在某个运行级别下启动
```
chkconfig --level <运行级别> --list <服务名>
```
7. 添加新的服务
```
chkconfig --add <服务名>
```
8. 删除服务
```
chkconfig --del <服务名>
```
相关问题
linux 查看开机启动服务
在 Linux 中,可以使用以下命令查看开机启动的服务:
1. systemctl:
```
systemctl list-unit-files --type=service
```
该命令将列出已安装的所有服务及其状态,包括已启用的服务和禁用的服务。
2. chkconfig:
```
chkconfig --list
```
该命令将列出所有已安装的服务及其启动级别,包括已启用的服务和禁用的服务。
3. service:
```
service --status-all
```
该命令将列出已安装的所有服务及其状态,包括已启用的服务和禁用的服务。
linux服务开机自启动
在Linux中,可以通过将服务添加到系统启动脚本中来实现服务开机自启动。具体步骤如下:
1. 编写服务启动脚本,通常以.sh或.service为后缀名,并将其放置在/etc/init.d/目录下。
2. 使用chkconfig命令将服务添加到系统启动脚本中,例如:
chkconfig --add servicename
3. 使用chkconfig命令设置服务的启动级别,例如:
chkconfig --level 345 servicename on
这将在系统启动时自动启动该服务,并在运行级别3、4、5下启用该服务。
注意:以上命令需要root权限才能执行。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)