linux ubuntu chkconfig 无效利用sysv-rc-conf 设置自启

本文介绍了在Linux系统中遇到chkconfig命令不可用的问题及解决方案。通过安装sysv-rc-conf包来修复chkconfig命令,并展示了如何使用该命令管理系统的启动服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

chkconfig 命令无效

root@iZ2ze9dhxbd6xwizhjqbloZ:/usr/java# chkconfig
chkconfig: command not found
root@iZ2ze9dhxbd6xwizhjqbloZ:/usr/java# 

安装 sysv-rc-conf

root@iZ2ze9dhxbd6xwizhjqbloZ:/usr/java#  rpm -aq |grep chkconfig
root@iZ2ze9dhxbd6xwizhjqbloZ:/usr/java# apt-get install sysv-rc-conf
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libcurses-perl libcurses-ui-perl libterm-readkey-perl
The following NEW packages will be installed:
  libcurses-perl libcurses-ui-perl libterm-readkey-perl sysv-rc-conf
0 upgraded, 4 newly installed, 0 to remove and 181 not upgraded.
Need to get 367 kB of archives.
After this operation, 1,263 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe i386 libcurses-perl i386 1.33-1build1 [86.6 kB]
Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe i386 libterm-readkey-perl i386 2.33-1build1 [28.2 kB]
Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe i386 libcurses-ui-perl all 0.9609-1 [229 kB]
Get:4 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe i386 sysv-rc-conf all 0.99-7 [22.7 kB]
Fetched 367 kB in 0s (1,348 kB/s)  
Selecting previously unselected package libcurses-perl.
(Reading database ... 102296 files and directories currently installed.)
Preparing to unpack .../libcurses-perl_1.33-1build1_i386.deb ...
Unpacking libcurses-perl (1.33-1build1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../libterm-readkey-perl_2.33-1build1_i386.deb ...
Unpacking libterm-readkey-perl (2.33-1build1) ...
Selecting previously unselected package libcurses-ui-perl.
Preparing to unpack .../libcurses-ui-perl_0.9609-1_all.deb ...
Unpacking libcurses-ui-perl (0.9609-1) ...
Selecting previously unselected package sysv-rc-conf.
Preparing to unpack .../sysv-rc-conf_0.99-7_all.deb ...
Unpacking sysv-rc-conf (0.99-7) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libcurses-perl (1.33-1build1) ...
Setting up libterm-readkey-perl (2.33-1build1) ...
Setting up libcurses-ui-perl (0.9609-1) ...
Setting up sysv-rc-conf (0.99-7) ...

直接加入启动程序,例如把 /etc/init.d/tomcat加入到系统自动 启动列表中:

  sysv-rc-conf tomcat on   //开启
  sysv-rc-conf tomcat off  //关闭

centos 跟ubuntu 还是有区别的!

sysv-rc-conf 命令执行效果
这里写图片描述

<think>好的,我现在需要解决用户的问题:“如何在bash中解决chkconfig command not found问题”。首先,我得回忆一下关于chkconfig的相关知识。 用户提到在Ubuntu系统中使用chkconfig命令时出现“command not found”错误。我记得chkconfig是Red Hat系列的Linux发行版(比如CentOS、Fedora)中用来管理系统服务的工具,而Ubuntu属于Debian系列,通常使用不同的服务管理工具,比如update-rc.d或者systemctl。因此,Ubuntu默认没有安装chkconfig,这应该是导致错误的原因。 接下来,用户需要解决这个问题,可能的解决方法有两种:一种是安装chkconfig的替代工具,另一种是使用Ubuntu自带的工具。根据引用[2],Ubuntu推荐使用sysv-rc-conf来代替chkconfig。所以,我应该建议用户安装sysv-rc-conf。安装命令通常是使用apt-get,但需要先更新软件包列表,确保安装顺利。 另外,用户可能还希望直接使用chkconfig,虽然不推荐,但如果有特殊需求,可能需要从源代码或其他途径安装。不过,这种情况下可能兼容性不好,所以最好推荐使用替代工具。此外,现在很多系统已经转向systemd,使用systemctl命令来管理服务,这也是一个可以考虑的解决方案,但需要确认用户的系统是否支持systemd。 总结起来,步骤应该是: 1. 安装sysv-rc-conf。 2. 使用sysv-rc-conf来管理服务。 3. 或者,使用systemctl命令(如果可用)。 4. 或者,安装chkconfig包(虽然不推荐)。 需要确保用户按照正确的步骤操作,并注意不同命令的语法差异。例如,sysv-rc-conf的使用方法和chkconfig类似,但可能有细微的不同,需要用户适应。同时,提醒用户在Ubuntu中更推荐使用原生工具,以避免兼容性问题。</think>### 如何解决`chkconfig: command not found`问题? #### 问题原因 `chkconfig`是Red Hat系列Linux系统(如CentOS)中用于管理系统服务的工具,而Ubuntu等Debian系列系统默认不包含此命令[^2]。 --- #### 解决方法 ##### 方法1:使用替代工具`sysv-rc-conf` 1. **安装`sysv-rc-conf`** 更新软件包列表并安装: ```bash sudo apt-get update sudo apt-get install sysv-rc-conf ``` 2. **基本使用** - 查看服务状态: ```bash sudo sysv-rc-conf --list ``` - 用/禁用服务(交互式界面): ```bash sudo sysv-rc-conf ``` ##### 方法2:使用`systemctl`(推荐) 若系统支持`systemd`(Ubuntu 15.04+默认),可直接使用`systemctl`: - 查看服务状态: ```bash systemctl status <service-name> ``` - 用服务开机动: ```bash sudo systemctl enable <service-name> ``` - 禁用开机动: ```bash sudo systemctl disable <service-name> ``` ##### 方法3:手动安装`chkconfig`(不推荐) 若需强制使用`chkconfig`,可尝试安装兼容包: ```bash sudo apt-get install chkconfig ``` 但需注意:部分功能可能不兼容Ubuntu--- #### 注意事项 - **兼容性**:Ubuntu更推荐使用`systemctl`或`sysv-rc-conf`。 - **命令差异**:`sysv-rc-conf`的操作界面与`chkconfig`类似,但参数可能不同。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Java小技巧

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值