How to List Services in Ubuntu Server
In this blog we are going to learn how to list services in Ubuntu using the commands. We will see how we can list running services and services that are not running.
1. Using service
command
The service --status-all
command will list all services on your Ubuntu Server (Both running services and Not running Services).
bash
$ service --status-all
Sample outputs from Ubuntu server
vagrant@ubuntu-bionic:~$ service --status-all
[ - ] acpid
[ + ] apparmor
[ + ] apport
[ + ] atd
[ - ] cgroupfs-mount
[ - ] console-setup.sh
[ + ] cron
[ - ] cryptdisks
[ - ] cryptdisks-early
[ + ] dbus
[ + ] docker
[ + ] ebtables
[ + ] grub-common
[ - ] hwclock.sh
[ + ] irqbalance
[ + ] iscsid
[ - ] keyboard-setup.sh
[ + ] kmod
[ - ] lvm2
[ + ] lvm2-lvmetad
[ + ] lvm2-lvmpolld
[ + ] lxcfs
[ - ] lxd
[ - ] mdadm
[ - ] mdadm-waitidle
[ - ] open-iscsi
[ - ] open-vm-tools
[ - ] plymouth
[ - ] plymouth-log
[ + ] procps
[ - ] rsync
[ + ] rsyslog
[ - ] screen-cleanup
[ + ] ssh
[ + ] udev
[ + ] ufw
[ + ] unattended-upgrades
[ - ] uuidd
[ + ] virtualbox-guest-utils
The meaning of the Ubuntu service command output
This will show all available services on your Ubuntu System. The status is [ + ] for running services, [ - ] for stopped services
.
From the Ubuntu Linux service man page
service --status-all
runs all init scripts, in alphabetical order, with the status command. The status is:
- [ + ] for running services
- [ - ] for stopped services
- [ ? ] for services without a ‘status’ command
Show only the running services
Using the grep
command, we can filter the output to show only the running services.
$ service --status-all | grep '\[ + \]'
Show only the not running services
To list ubuntu services that are not running, Type
$ service --status-all | grep '\[ - \]'
2. List Services with systemctl
command
Since Ubuntu 15.04, the services are managed by the systemd
. With systemd
we can use systemctl
command to get information about running services in our Ubuntu system.
To list all running services on Ubuntu, Type
$ systemctl list-units
Sample output from Ubuntu 16.04
vagrant@ubuntu-bionic:~$ systemctl list-units
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
sys-devices-pci0000:00-0000:00:03.0-net-enp0s3.device loaded active plugged 82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapter)
sys-devices-pci0000:00-0000:00:08.0-net-enp0s8.device loaded active plugged 82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapter)
sys-devices-pci0000:00-0000:00:14.0-host2-target2:0:0-2:0:0:0-block-sda-sda1.device loaded active plugged HARDDISK cloudimg-rootfs
sys-devices-pci0000:00-0000:00:14.0-host2-target2:0:0-2:0:0:0-block-sda.device loaded active plugged HARDDISK
sys-devices-pci0000:00-0000:00:14.0-host2-target2:0:1-2:0:1:0-block-sdb.device loaded active plugged HARDDISK cidata
sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS1
sys-devices-platform-serial8250-tty-ttyS10.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS10
sys-devices-platform-serial8250-tty-ttyS11.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS11
sys-devices-platform-serial8250-tty-ttyS12.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS12
sys-devices-platform-serial8250-tty-ttyS13.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS13
sys-devices-platform-serial8250-tty-ttyS14.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS14
sys-devices-platform-serial8250-tty-ttyS15.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS15
sys-devices-platform-serial8250-tty-ttyS16.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS16
sys-devices-platform-serial8250-tty-ttyS17.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS17
sys-devices-platform-serial8250-tty-ttyS18.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS18
sys-devices-platform-serial8250-tty-ttyS19.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS19
sys-devices-platform-serial8250-tty-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2
List only active
services
systemctl list-units -a
Sample output:
vagrant@ubuntu-bionic:~$ systemctl list-units -a
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
dev-disk-by\x2dlabel-cidata.device loaded active plugged HARDDISK cidata
dev-disk-by\x2dlabel-cloudimg\x2drootfs.device loaded active plugged HARDDISK cloudimg-rootfs
dev-disk-by\x2dpartuuid-3b5bac20\x2d01.device loaded active plugged HARDDISK cloudimg-rootfs
dev-disk-by\x2dpath-pci\x2d0000:00:14.0\x2dscsi\x2d0:0:0:0.device loaded active plugged HARDDISK
dev-disk-by\x2dpath-pci\x2d0000:00:14.0\x2dscsi\x2d0:0:0:0\x2dpart1.device loaded active plugged HARDDISK cloudimg-rootfs
dev-disk-by\x2dpath-pci\x2d0000:00:14.0\x2dscsi\x2d0:0:1:0.device loaded active plugged HARDDISK cidata
dev-disk-by\x2duuid-2019\x2d11\x2d05\x2d16\x2d01\x2d29\x2d00.device loaded active plugged HARDDISK cidata
dev-disk-by\x2duuid-cbe5c91c\x2d3cdd\x2d4006\x2dbd0c\x2d05f1bfb67591.device loaded active plugged HARDDISK cloudimg-rootfs
dev-rfkill.device loaded active plugged /dev/rfkill
dev-sda.device loaded active plugged HARDDISK
dev-sda1.device loaded active plugged HARDDISK cloudimg-rootfs
dev-sdb.device loaded active plugged HARDDISK cidata
dev-ttyprintk.device loaded active plugged /dev/ttyprintk
List only inactive
services
systemctl list-units -a --state=inactive
Sample output:
vagrant@ubuntu-bionic:~$ systemctl list-units -a --state=inactive
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.mount loaded inactive dead Arbitrary Executable File Formats File System
● tmp.mount not-found inactive dead tmp.mount
apport-autoreport.path loaded inactive dead Process error reports when automatic reporting is enabled (file watch)
systemd-ask-password-plymouth.path loaded inactive dead Forward Password Requests to Plymouth Directory Watch
acpid.service loaded inactive dead ACPI event daemon
apport-autoreport.service loaded inactive dead Process error reports when automatic reporting is enabled
apt-daily-upgrade.service loaded inactive dead Daily apt upgrade and clean activities
apt-daily.service loaded inactive dead Daily apt download activities
● auditd.service not-found inactive dead auditd.service
● connman.service not-found inactive dead connman.service
● console-screen.service not-found inactive dead console-screen.service
● display-manager.service not-found inactive dead display-manager.service
dm-event.service loaded inactive dead Device-mapper event daemon
emergency.service loaded inactive dead Emergency Shell
● fcoe.service not-found inactive dead fcoe.service
● firewalld.service not-found inactive dead firewalld.service
fstrim.service loaded inactive dead Discard unused blocks
The systemctl command does not work for Ubuntu 14.04
and earlier releases, instead use the service --status-all
command mentioned above.