简短答案:
bad
:显示Systemd Unit files
启用状态
- 您将在使用以下内容的系统上看到此类消息
systemd
您可以使用以下命令检查启用状态:
sudo systemctl is-enabled <unit-name>
如果该单元文件是本机systemd服务,则它将提供output enabled
,disabled
等等。如果它不是本机systemd服务,则将给出报告消息。
sudo systemctl is-enabled apache2
apache2.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install is-enabled apache2
enabled
但是用命令:
systemctl status apache2
or
service apache2 status
它赋予地位bad
。(也许是因为它无法打印完整的消息或开发者决定打印bad
)
长答案:
什么是系统单位文件?
单元是systemd知道如何管理的对象。这些基本上是系统资源的标准化表示形式,可以由守护程序套件进行管理,并由提供的实用程序进行操作。它可以用于抽象服务,网络资源,设备,文件系统挂载和隔离的资源池。您可以在此处和此处详细了解有关systemd单位的信息
例:
systemctl status apache2
* apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
`-apache2-systemd.conf
Active: active (running) since Wed 2016-10-12 14:29:42 UTC; 17s ago
Docs: man:systemd-sysv-generator(8)
Process: 1027 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
systemctl将检查是否apache2
是本机单元。如果不是,那么它将要求systemd-sysv-generator
生成单位格式的文件,该文件提供类似于本机单位的支持。在上面的示例中,生成的文件保存在
/lib/systemd/system/apache2.service.d/apache2-systemd.conf
Drop-In: /lib/systemd/system/apache2.service.d
`-apache2-systemd.conf
注意:您可以在以下位置找到生成器,/lib/systemd/system-generators/systemd-sysv-generator
并可以阅读更多有关该生成器的信息。
man systemd-sysv-generator
要点:
is-enabled NAME...
Checks whether any of the specified unit files are enabled (as with
enable). Returns an exit code of 0 if at least one is enabled,
non-zero otherwise. Prints the current enable status (see table).
To suppress this output, use --quiet.
Table 1. is-enabled output
+------------------+-------------------------+-----------+
|Name | Description | Exit Code |
+------------------+-------------------------+-----------+
|"enabled" | Enabled via | |
+------------------+ .wants/, .requires/ | |
|"enabled-runtime" | or alias symlinks | |
| | (permanently in | 0 |
| | /etc/systemd/system/, | |
| | or transiently in | |
| | /run/systemd/system/). | |
+------------------+-------------------------+-----------+
|"linked" | Made available through | |
+------------------+ one or more symlinks | |
|"linked-runtime" | to the unit file | |
| | (permanently in | |
| | /etc/systemd/system/ | |
| | or transiently in | > 0 |
| | /run/systemd/system/), | |
| | even though the unit | |
| | file might reside | |
| | outside of the unit | |
| | file search path. | |
+------------------+-------------------------+-----------+
|"masked" | Completely disabled, | |
+------------------+ so that any start | |
|"masked-runtime" | operation on it fails | |
| | (permanently in | > 0 |
| | /etc/systemd/system/ | |
| | or transiently in | |
| | /run/systemd/systemd/). | |
+------------------+-------------------------+-----------+
|"static" | The unit file is not | 0 |
| | enabled, and has no | |
| | provisions for enabling | |
| | in the "[Install]" | |
| | section. | |
+------------------+-------------------------+-----------+
|"indirect" | The unit file itself is | 0 |
| | not enabled, but it has | |
| | a non-empty Also= | |
| | setting in the | |
| | "[Install]" section, | |
| | listing other unit | |
| | files that might be | |
| | enabled. | |
+------------------+-------------------------+-----------+
|"disabled" | Unit file is not | > 0 |
| | enabled, but contains | |
| | an "[Install]" section | |
| | with installation | |
| | instructions. | |
+------------------+-------------------------+-----------+
|"bad" | Unit file is invalid or | > 0 |
| | another error occurred. | |
| | Note that is-enabled | |
| | will not actually | |
| | return this state, but | |
| | print an error message | |
| | instead. However the | |
| | unit file listing | |
| | printed by | |
| | list-unit-files might | |
| | show it. | |
+------------------+-------------------------+-----------+
如果我们运行命令:
sudo systemctl is-enabled ssh
enabled
sudo systemctl is-enabled docker
enabled
sudo systemctl is-enabled apache2
apache2.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install is-enabled apache2
enabled
您可以看到单位是否像ssh
和一样是systemd的本机docker
,在上面的输出中,它将仅显示enabled
,而对于不是像本机apache2
但仍启用bad
的本机,由于这种情况,它给出的消息而不是在此处打印:
+------------------+-------------------------+-----------+
|"bad" | Unit file is invalid or | > 0 |
| | another error occurred. | |
| | Note that is-enabled | |
| | will not actually | |
| | return this state, but | |
| | print an error message | |
| | instead. However the | |
| | unit file listing | |
| | printed by | |
| | list-unit-files might | |
| | show it. | |
+------------------+-------------------------+-----------+
解:
状态bad
不会造成问题(我不确定这取决于问题),但不会提供的所有功能systemctl
。您可以等待下一个package
本机支持的版本systemd
。或者您可以使用给定的引用为服务或任何其他资源编写单元文件。
您可以使用以下参考文献详细了解systemd,systemctl和units:
系统控制
系统单位和此处
系统化