网站首页 > 技术文章 正文
# bash: chkconfig: command not found 解决方法
## 一、chkconfig 错误描述:
这个错误表明在 Bash 环境下,尝试执行 chkconfig 命令,但是系统找不到这个命令。chkconfig 命令是一个用于管理 Linux 系统中服务的启动和停止的工具,通常它是 initscripts 包的一部分,但在最新的 Linux 发行版中可能已经被 systemd 命令取代。
## 二、解决方法:
### 1、如果你的系统使用的是 systemd,你可以使用 systemctl 命令来管理服务。例如,启用或禁用服务可以使用以下命令:
```bash
# 启用服务:
sudo systemctl enable servicename
# 禁用服务:
sudo systemctl disable servicename
```
### 2、如果你系统是完全基于 systemd 的最新 Linux 发行版,使用 systemctl 命令而不是 chkconfig 命令,你可以对比学习两个命令,sysvinit 命令与 systemctl 命令的语法相似。对比如下:
| Sysvinit command | Systemd command |
|--|--|
| service service_name start |systemctl start service_name |
| service service_name stop | systemctl stop service_name |
| service service_name restart | systemctl restart service_name |
| service service_name status | systemctl status service_name |
| chkconfig service_name on | systemctl enable service_name |
| chkconfig service_name off | systemctl disable service_name |
### 3、如果你的系统仍然使用 SysVinit 或 upstart,并且确实需要使用 chkconfig 命令,你需要安装 chkconfig 命令。
```bash
# 在 RedHat 或 CentOS 系统上 安装 chkconfig 命令,因为 chkconfig 命令是 initscripts 包的一部分
sudo yum install initscripts
# 在 Debian 或 Ubuntu 系统上安装 chkconfig 命令,因为 chkconfig 命令是 initscripts 包的一部分
sudo apt-get install initscripts
# 或者安装 sysvinit-utils, chkconfig 命令也存在 sysvinit-utils 包
sudo apt-get install sysvinit-utils
# 或者安装 sysv-rc, 在 Debian 或 Ubuntu 系统上,chkconfig 命令已经被 sysv-rc 命令代替
sudo apt-get install sysv-rc
sudo apt-get install sysv-rc-conf
# 复制命令并更改命令名称
cp /usr/sbin/sysv-rc-conf /usr/sbin/chkconfig
#
```
### 4、确认你的 PATH 环境变量是否包含了 chkconfig 命令所在的目录。
```bash
# 查看当前的 PATH 变量
echo $PATH
# 如果你的 PATH 环境变量 不包含 chkconfig 命令目录,你需要添加相应路径
sudo vim /etc/profile
# 添加 chkconfig 命令 相应的路径。
export CHKCONFIG_HOME=/yourpath
export PATH=${CHKCONFIG_HOME}/bin:$PATH
```
### 5、如果你正在使用一个容器(如Docker)或者特殊的环境,确保你的环境支持chkconfig 或 systemctl。
- 上一篇: 宽带提速利器(宽带提速平台)
- 下一篇: ERPNext安装过程中遇到的坑及对应解决方案
猜你喜欢
- 2024-10-14 Ubuntu19.10系统的软件安装与卸载命令
- 2024-10-14 VMware下安装VMware tools,安装文件没有出现问题的解决
- 2024-10-14 大白话 linux 教程-09-安装和卸载软件包
- 2024-10-14 ubuntu下安装ssh(ubuntu下安装windows10)
- 2024-10-14 蓝易云 - Ubutun开机黑屏解决方法
- 2024-10-14 银河麒麟系统密码忘记了,修改密码和微信安装方法
- 2024-10-14 ubuntu离线apt-get更新源(ubuntu 离线升级)
- 2024-10-14 树莓派安装opencv3.4.0遇到的坑(树莓派安装opencv完整过程)
- 2024-10-14 linux 系统 没有 ifconfig 命令,提示: ifconfig: command not found
- 2024-10-14 go get 命令一直下载不了源站的包解决方案
- 02-21走进git时代, 你该怎么玩?_gits
- 02-21GitHub是什么?它可不仅仅是云中的Git版本控制器
- 02-21Git常用操作总结_git基本用法
- 02-21为什么互联网巨头使用Git而放弃SVN?(含核心命令与原理)
- 02-21Git 高级用法,喜欢就拿去用_git基本用法
- 02-21Git常用命令和Git团队使用规范指南
- 02-21总结几个常用的Git命令的使用方法
- 02-21Git工作原理和常用指令_git原理详解
- 最近发表
- 标签列表
-
- cmd/c (57)
- c++中::是什么意思 (57)
- sqlset (59)
- ps可以打开pdf格式吗 (58)
- phprequire_once (61)
- localstorage.removeitem (74)
- routermode (59)
- vector线程安全吗 (70)
- & (66)
- java (73)
- org.redisson (64)
- log.warn (60)
- cannotinstantiatethetype (62)
- js数组插入 (83)
- resttemplateokhttp (59)
- gormwherein (64)
- linux删除一个文件夹 (65)
- mac安装java (72)
- reader.onload (61)
- outofmemoryerror是什么意思 (64)
- flask文件上传 (63)
- eacces (67)
- 查看mysql是否启动 (70)
- java是值传递还是引用传递 (58)
- 无效的列索引 (74)