33
$ sudo service cassandra status
● cassandra.service - LSB: distributed storage system for structured data
   Loaded: loaded (/etc/init.d/cassandra; bad; vendor preset: enabled)
   Active: active (running) since Wed 2016-10-12 15:54:40 IDT; 4min 4s ago

What does the bad; part on the 2nd line of the output stand for? I get this for many services, e.g. mysql, winbind, virtualbox, some of which I've flawlessly used already (cassandra being a fresh install).

43

Short answer:

  • bad : It shows Systemd Unit files enablement status
  • you will see this sort of message on systems which use systemd
  • you can check the enablement status using command:

    sudo systemctl is-enabled <unit-name>
    

    if that unit file is a native systemd service then it will give output enabled, disabled, etc. If it is not a native systemd service then it will give report a message like.

    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
    

    but with command :

    systemctl status apache2
    or
    service apache2 status
    

    it gives status bad. (maybe it is because it is not able to print a complete message or developer decided to print bad)

Long Answer:

what are system unit files ?

Units are the objects that systemd knows how to manage. These are basically a standardized representation of system resources that can be managed by the suite of daemons and manipulated by the provided utilities. It can be used to abstract services, network resources, devices, filesystem mounts, and isolated resource pools. You can read in detail about systemd units here and here

example:

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 will check if apache2 is a native unit or not. If not, then it will ask systemd-sysv-generator to generate a file in unit format that provides support similar to native units. In the above example, the generated file is kept at /lib/systemd/system/apache2.service.d/apache2-systemd.conf

Drop-In: /lib/systemd/system/apache2.service.d
               `-apache2-systemd.conf

Note: you can find the generator at /lib/systemd/system-generators/systemd-sysv-generator and you can read more about that

man systemd-sysv-generator

Main point:

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.                |           |
       +------------------+-------------------------+-----------+

if we run the command :

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

you can see if units are native to systemd like ssh and docker, in the above output it will show only enabled, and for units that are not native like apache2 but still enabled it gives messages with that rather than printing bad here because of this condition:

       +------------------+-------------------------+-----------+
       |"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.                |           |
       +------------------+-------------------------+-----------+

Solution:

status bad will not create problem (i am not sure it depends) but it will not provide all functionality of systemctl. you can wait for next release of that package that will natively support systemd. or you can write unit file for your service or any other resource using given references.

You can read in detail about systemd , systemctl and units using below References :

  1. Systemctl

  2. Systemd units and Here

  3. Systemd

  • Really thanks for the complete and considerate deliberation of the topic! – matt Oct 16 '16 at 7:54
  • 2
    This answer seems really complete but is kind of confusing...you seem to provide lots of info without actually stating the succinct conclusion that one could (maybe) derive from the info. For example the direct, succinct conclusion I infer (with some work) from your short answer is that when a service (systemd unit) is not native, systemctl cannot get its enablement status without redirecting to systemd-sysv-install. The systemctl status command for some reason does not do that but instead reports "bad", whereas systemctl is-enabled will do the redirect to give you the status. – EricS Jun 1 '18 at 23:26
  • 1
    I think some of what confused me was some wording, especially in the opening bullet points. I submitted some edits to try to improve. – EricS Jun 1 '18 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.