I need to identify the currently running services but I can't figure out the results of running service --status-all, I mean what does ?, - and + mean ?
$ service --status-all [ + ] acpid [ + ] anacron [ + ] apparmor [ ? ] apport [ ? ] atieventsd [ + ] avahi-daemon [ ? ] binfmt-support [ + ] bluetooth [ - ] brltty [ + ] console-font [ + ] console-setup [ + ] cron [ + ] cups [ + ] cups-browsed [ - ] dbus [ ? ] dns-clean [ + ] friendly-recovery [ - ] grub-common [ ? ] irqbalance [ - ] kerneloops [ ? ] killprocs [ + ] kmod [ ? ] lightdm [ - ] lm-sensors [ ? ] mysql [ ? ] networking [ ? ] ondemand [ ? ] pppd-dns [ - ] procps [ - ] pulseaudio [ ? ] rc.local [ + ] resolvconf [ + ] rfkill-restore [ + ] rfkill-store [ - ] rsync [ + ] rsyslog [ + ] saned [ ? ] sendsigs [ + ] setvtrgb [ ? ] speech-dispatcher [ - ] sudo [ + ] timidity [ + ] udev [ ? ] umountfs [ ? ] umountnfs.sh [ ? ] umountroot [ - ] unattended-upgrades [ - ] urandom [ + ] virtualbox [ - ] x11-commonAnd would running this command with sudo make any difference ? I tried it and in my case it didn't make any difference, but may it differ in other setups ?
04 Answers
The output of service --status-all lists the state of services controlled by System V.
The + indicates the service is running, - indicates a stopped service. You can see this by running service SERVICENAME status for a + and - service.
Some services are managed by Upstart. You can check the status of all Upstart services with sudo initctl list. Any service managed by Upstart will also show in the list provided by service --status-all but will be marked with a ?.
Reference: man service
It's not documented in the manpage, but a quick look at the source confirms the first guess:
+: the service is running-: the service is not running?: the service state cannot be determined (for some reason).
if ! is_ignored_file "${SERVICE}" \ && [ -x "${SERVICEDIR}/${SERVICE}" ]; then if ! grep -qs "\(^\|\W\)status)" "$SERVICE"; then #printf " %s %-60s %s\n" "[?]" "$SERVICE:" "unknown" 1>&2 echo " [ ? ] $SERVICE" 1>&2 continue else out=$(env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1) if [ "$?" = "0" -a -n "$out" ]; then #printf " %s %-60s %s\n" "[+]" "$SERVICE:" "running" echo " [ + ] $SERVICE" continue else #printf " %s %-60s %s\n" "[-]" "$SERVICE:" "NOT running" echo " [ - ] $SERVICE" continue fi fi #env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status fiThe conditions are:
- if the init script doesn't support a
statuscommand, the state is?. - if the init script (with the
statusargument) exit status is zero and output is not empty, the state is+. - otherwise the state is
-.
I believe that + means the service is active/running, - means it is inactive/stopped, and ? means that the command cannot conclusively determine whether it is active or not, as the service does not have a status command in the service script. The service --status-all command actually runs service <service-name> status for every available service.
I find that running with/without sudo makes a difference.
Some services in /var/run/ have read access only to root user. Those services show status [-] without sudo, and [+] with sudo.