简体   繁体   English

如何在 Ubuntu 上安装 chkconfig?

[英]How do I install chkconfig on Ubuntu?

I am running Ubuntu 13.10, and I'm pretty new to Linux.我正在运行 Ubuntu 13.10,我对 Linux 还很陌生。 I tried:我试过:

$ sudo apt-get install chkconfig

Package chkconfig is not available, but is referred to by another package.包 chkconfig 不可用,但被另一个包引用。 This may mean that the package is missing, has been obsoleted, or is only available from another source这可能意味着软件包丢失、已过时或只能从其他来源获得

E: Package 'chkconfig' has no installation candidate E: 包 'chkconfig' 没有安装候选

I manually downloaded the package and unzipped it.我手动下载了这个包并解压了它。 The resulting folder has a file called:生成的文件夹中有一个名为:

chkconfig.install

But how do I run this?但是我该如何运行呢? I tried this, but it didn't work.我试过这个,但没有用。

$ sudo chkconfig.install

The command chkconfig is no longer available in Ubuntu.The equivalent command to chkconfig is update-rc.d .This command nearly supports all the new versions of ubuntu.命令chkconfig不再可用在Ubuntu.The相当于命令chkconfigupdate-rc.d 。这个命令几乎支持Ubuntu的所有新版本。

The similar commands are类似的命令是

update-rc.d <service> defaults

update-rc.d <service> start 20 3 4 5

update-rc.d -f <service>  remove

In Ubuntu /etc/init.d has been replaced by /usr/lib/systemd.在 Ubuntu 中 /etc/init.d 已被 /usr/lib/systemd 取代。 Scripts can still be started and stoped by 'service'.脚本仍然可以通过“服务”启动和停止。 But the primary command is now 'systemctl'.但主要命令现在是“systemctl”。 The chkconfig command was left behind, and now you do this with systemctl. chkconfig 命令被抛在后面,现在您可以使用 systemctl 来执行此操作。

So instead of:所以而不是:

chkconfig enable apache2

You should look for the service name, and then enable it您应该查找服务名称,然后启用它

systemctl status apache2
systemctl enable apache2.service

Systemd has become more friendly about figuring out if you have a systemd script, or an /etc/init.d script, and doing the right thing. Systemd 在判断您是否有 systemd 脚本或 /etc/init.d 脚本并做正确的事情方面变得更加友好。

sysv-rc-conf is an alternate option for Ubuntu. sysv-rc-conf 是 Ubuntu 的替代选项。

sudo apt-get install sysv-rc-conf

sysv-rc-conf --list xxxx
alias chkconfig=sysv-rc-conf
chkconfig --list

syntax语法

sysv-rc-conf command line usage:  

        sysv-rc-conf --list [service name]
        sysv-rc-conf [--level <runlevels>] <service name> <on|off>

Chkconfig is no longer available in Ubuntu . Chkconfig 在 Ubuntu 中不再可用

Chkconfig is a script. Chkconfig 是一个脚本。 You can download it from here .你可以从这里下载。

Install this package in Ubuntu :Ubuntu安装这个包:

apt install sysv-rc-conf

its a substitute for chkconfig cmd.它是chkconfig cmd 的替代品。

After install run this cmd:安装后运行这个cmd:

sysv-rc-conf --list

It'll show all services in all the runlevels.它将显示所有运行级别中的所有服务。 You can also run this:你也可以运行这个:

sysv-rc-conf --level (runlevel number ex:1 2 3 4 5 6 )

Now you can choose which service should be active in boot time.现在您可以选择启动时应激活的服务。

But how do I run this?但是我该如何运行呢? I tried typing: sudo chkconfig.install which doesn't work.我尝试输入: sudo chkconfig.install这不起作用。

I'm not sure where you got this package or what it contains;我不确定你从哪里得到这个包或它包含什么; A url of download would be helpful.下载网址会有所帮助。 Without being able to look at the contents of chkconfig.install;无法查看 chkconfig.install 的内容; I'm surprised to find a unix tool like chkconfig to be bundled in a zip archive, maybe it is still yet to be uncompressed, a tar.gz?我很惊讶地发现像 chkconfig 这样的 unix 工具被捆绑在一个 zip 存档中,也许它还没有被解压缩,一个 tar.gz? but maybe it is a shell script?但也许它是一个shell脚本?

I should suggest editing it and seeing what you are executing.我应该建议编辑它并查看您正在执行的操作。

sh chkconfig.install or ./chkconfig.install ; sh chkconfig.install./chkconfig.install which might work....but my suggestion would be to learn to use update-rc.d as the other answers have suggested but do not speak directly to the question...which is pretty hard to answer without being able to look at the data yourself.这可能有效......但我的建议是学习使用 update-rc.d 作为其他答案的建议,但不要直接回答这个问题......如果不看就很难回答自己的数据。

As mentioned by @jerry you can add services with the below command.正如@jerry 所提到的,您可以使用以下命令添加服务。

update-rc.d <service> defaults
update-rc.d <service> start 20 3 4 5
update-rc.d -f <service>  remove

To validate them check the above commands you can check /etc/rc*.d/ directory where service start with "k" means it will not execute during the boot and service start with "S" will start during the boot.要验证它们,请检查上述命令,您可以检查 /etc/rc*.d/ 目录,其中以“k”开头的服务意味着它不会在引导期间执行,而以“S”开头的服务将在引导期间启动。

# for runlevel symlinks:
ls /etc/rc*.d/

In the below screenshot you can see apache2 starting in runlevel2(S02apache2) and stopping in runlevel1(K01apache2)在下面的屏幕截图中,您可以看到 apache2 从 runlevel2(S02apache2) 开始并在 runlevel1(K01apache2) 停止

在此处输入图片说明

在此处输入图片说明

You can also check the service status with the below command where "+" means service is in running state "-" is in stopped.您还可以使用以下命令检查服务状态,其中“+”表示服务处于运行状态,“-”表示停止。

service --status-all

在此处输入图片说明

OR

install sysv-rc-conf utility.安装 sysv-rc-conf 实用程序。

apt-get install sysv-rc-conf
example
sysv-rc-conf --level 2345 apach22 on
man sysv-rc-conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM