Learn Modern Service Management System (Systemd) on Linux

LinuxOperating Systemserver

systemd is a framework and service manager for Linux operating system. At a point when keep running as the first process on boot (as PID 1), it goes about as init system. that raises and keeps up userspace services.This article explains -“Learn modern service management system (Systemd) on Linux”

To get more information about systemd, use the following command as shown below –

$ systemd -h

The sample output should be like this –

Starts up and maintains the system or user services.

-h --help                                           Show this help
--test                                              Determine startup sequence, dump it and exit
--no-pager                                          Do not pipe output into a pager
--dump-configuration-items                          Dump understood unit configuration items
--unit=UNIT                                         Set default unit
--system                                            Run a system instance, even if PID != 1
--user                                              Run a user instance
--dump-core[=BOOL]                                  Dump core on crash
--crash-vt=NR                                       Change to specified VT on crash
--crash-reboot[=BOOL]                               Reboot on crash
--crash-shell[=BOOL]                                Run shell on crash
.......................................................................................

Version Information

To get the version information about systemd, use the following command as shown below –

$ systemd --version

The sample output should be like this –

systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
+GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN

Determine Startup Sequence

To determine startup sequence, use the following command as shown below –

$ systemd --test

The sample output should be like this –

State Change Timestamp: Mon 2017-01-30 11:15:37 IST
               Inactive Exit Timestamp: Mon 2017-01-30 11:15:37 IST
               Active Enter Timestamp: Mon 2017-01-30 11:15:37 IST
               Active Exit Timestamp: n/a
               Inactive Enter Timestamp: n/a
               GC Check Good: yes
               Need Daemon Reload: no
               Transient: no
               Slice: n/a
               CGroup: n/a
               CGroup realized: no
               CGroup mask: 0x0
               CGroup members mask: 0x0
               Name: sys-devices-platform-serial8250-tty-ttyS26.device
               Following Set Member: dev-ttyS26.device
               Job Timeout: 1min 30s
..............................................................................

Understanding unit configuration

To get the dump and to understand unit configuration items, use the following command –

$ systemd --dump-configuration-items

The sample output should be like this –

[Scope]
Slice=SLICE
CPUAccounting=BOOLEAN
CPUShares=SHARES
StartupCPUShares=SHARES
CPUQuota=OTHER
MemoryAccounting=BOOLEAN
MemoryLimit=LIMIT
DeviceAllow=DEVICE
DevicePolicy=POLICY
BlockIOAccounting=BOOLEAN
BlockIOWeight=WEIGHT
StartupBlockIOWeight=WEIGHT
BlockIODeviceWeight=DEVICEWEIGHT
BlockIOReadBandwidth=BANDWIDTH
.....................................................................................

Analyze Systemd Boot Process

To analyze systemd boot process, use the following command –

$ systemd-analyze

The sample output should be like this –

Startup finished in 8.740s (firmware) + 4.483s (loader) + 3.616s (kernel) + 4min 21.244s (userspace) = 4min 38.084s

List of booting process

To get the list booting process and its time, use the following command as shown below –

$ systemd-analyze blame

The sample output should be like this –

3min 59.399s apt-daily.service
      16.585s NetworkManager-wait-online.service
      11.182s grub-common.service
      9.532s apport.service
      9.224s irqbalance.service
      8.986s networking.service
      8.916s snapd.refresh.service
      8.859s speech-dispatcher.service
      7.709s dev-sda2.device
      7.641s gpu-manager.service
      7.641s rsyslog.service
      7.078s avahi-daemon.service
      6.178s lightdm.service
..............................................................................

Control Group Contents

To show control group contents, use the following command as shown below –

$ systemd-cgls

The sample output should be like this –

Control group /:
-.slice
├─init.scope
│ └─1 /lib/systemd/systemd --system --deserialize 19
├─system.slice
│ ├─avahi-daemon.service
│ │ ├─733 avahi-daemon: running [linux-Inspiron-3542.local
│ │ └─806 avahi-daemon: chroot helpe
│ ├─thermald.service
│ │ └─845 /usr/sbin/thermald --no-daemon --dbus-enable
│ ├─dbus.service
│ │ ├─ 759 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activ
│ │ └─2637 /usr/lib/x86_64-linux-gnu/fwupd/fwupd
│ ├─ModemManager.service
│ │ └─871 /usr/sbin/ModemManager
│ ├─cron.service
│ │ └─850 /usr/sbin/cron -f
│ ├─apache2.service
│ │ ├─ 4441 /usr/sbin/apache2 -k start

Top Control groups

To show top control groups by their resource usage, use the following command as shown below –

$sudo systemd-cgtop

The sample output should be like this –

Control Group                         Tasks          %CPU          Memory          Input/s       Output/s
/                                       -         20.0              6.3G             -               -
/init.scope                             1          -                 -               -               -
/system.slice                         125          -                 -               -               -
/user.slice                           695          -                 -               -               -
/user.slice/user-1000.slice           654          -                 -               -               -
/user.slice/user-126.slice             41          -                 -               -               -

Systemctl

Systemctl may be used to introspect and manage the state of the “systemd” system and service manager.

To get the more information about systemctl, use the following command as shown below –

$ systemctl --help

The sample output should be like this –

Query or send control commands to the systemd manager.

-h --help             Show this help
--version             Show package version
--system              Connect to system manager
--user                Connect to user service manager
-H --host=[USER@]HOST
                      Operate on remote host
-M --machine=CONTAINER
                      Operate on local container
-t --type=TYPE        List units of a particular type
--state=STATE         List units with particular LOAD or SUB or ACTIVE state
-p --property=NAME    Show only properties by this name
-a --all              Show all loaded units/properties, including dead/empty
                      ones. To list all units installed on the system, use
                      the 'list-unit-files' command instead.
-l --full             Don't ellipsize unit names on output
...........................................................................

Version Information

To get the version of systemctl, use the following command –

$ systemctl --version

The sample output should be like this –

systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
+GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN

List of all Services

To get the list of all running services, use the following command as shown below –

$ systemctl

The sample output should be like this –

UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Formats F
sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2deDP\x2d1-intel_backlight.device loaded
sys-devices-pci0000:00-0000:00:03.0-sound-card0.device loaded active plugged Haswell-ULT HD
sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device loaded active plugged 8 Series HD Aud
sys-devices-pci0000:00-0000:00:1c.2-0000:06:00.0-net-wlp6s0.device loaded active plugged QCA
sys-devices-pci0000:00-0000:00:1c.3-0000:07:00.0-net-enp7s0.device loaded active plugged RTL
sys-devices-pci0000:00-0000:00:1d.0-usb1-1\x2d1-1\x2d1.6-1\x2d1.6:1.0-bluetooth-hci0.device lo
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda3.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded act
sys-devices-pci0000:00-0000:00:1f.2-ata2-host1-target1:0:0-1:0:0:0-block-sr0.device loaded act
sys-devices-platform-dell\x2dlaptop-leds-dell::kbd_backlight.device loaded active plugged /s
sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform
sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform
sys-devices-platform-serial8250-tty-ttyS10.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS11.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS12.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS13.device loaded active plugged /sys/devices/platfor

Start service

To start a service using systemctl, use the following command as shown below –

$ sudo systemctl start application.service

The sample example to start service using systemctl as shown below –

$ sudo systemctl start bluetooth.service

Status of a service

To get the status of bluetooth.service as shown below –

$ systemctl status bluetooth

The sample output should be like this –

bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2017-01-27 09:32:45 IST; 3 days ago
Docs: man:bluetoothd(8)
Main PID: 954 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─954 /usr/lib/bluetooth/bluetoothd

Jan 30 10:10:22 linux-Inspiron-3542 bluetoothd[954]: gatt-time-server: Input/output error (5)
Jan 30 10:10:22 linux-Inspiron-3542 bluetoothd[954]: Not enough free handles to register service
Jan 30 10:10:22 linux-Inspiron-3542 bluetoothd[954]: Not enough free handles to register service
Jan 30 10:10:22 linux-Inspiron-3542 bluetoothd[954]: Sap driver initialization failed.
Jan 30 10:10:22 linux-Inspiron-3542 bluetoothd[954]: sap-server: Operation not permitted (1)
Jan 30 10:10:22 linux-Inspiron-3542 bluetoothd[954]: Endpoint registered: sender=:1.68 path=/Med
Jan 30 10:10:22 linux-Inspiron-3542 bluetoothd[954]: Endpoint registered: sender=:1.68 path=/Med
Jan 30 11:20:54 linux-Inspiron-3542 systemd[1]: Started Bluetooth service.
Jan 30 11:21:07 linux-Inspiron-3542 systemd[1]: Started Bluetooth service.
Jan 30 11:41:00 linux-Inspiron-3542 systemd[1]: Started Bluetooth service.

Stop a service

To stop a service, use the following command as shown below –

$ sudo systemctl stop bluetooth.service

To verify the above command, use the following command as shown below –

$ systemctl status bluetooth

The sample output should be like this –

bluetooth.service - Bluetooth service
  Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
  Active: inactive (dead) since Mon 2017-01-30 11:45:35 IST; 4s ago
    Docs: man:bluetoothd(8)
Main PID: 954 (code=exited, status=0/SUCCESS)
Status: "Quitting"
..................................................................................

Restart a service

To restarts a service, use the following command as shown below –

$ sudo systemctl restart bluetooth.service

Enable a service

To enables a service to be started on bootup, use the following command as shown below –

$ sudo systemctl enable bluetooth.service

Disabale a service

To disable a service to be started on bootup, use the following command as shown below –

$ sudo systemctl disable bluetooth.service

To verify whether service is enable or not, use the following command as shown below –

$ sudo systemctl is-enabled bluetooth.service; echo $?

The sample output should be like this –

enabled
0

Mask a service

To mask a service, use the following command as shown below –

$ sudo systemctl mask bluetooth.service

Unmask a service

To unmask a service, use the following command as shown below –

$ sudo systemctl unmask bluetooth.service

Kill a service

To kill a service, use the following command as shown below –

$ sudo systemctl kill bluetooth.service

Configuration details

To get the configuration details of a service, use the following command as shown below –

$ sudo systemctl show bluetooth

The sample output should be like this –

Restart=no
NotifyAccess=none
RestartUSec=100ms
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestampMonotonic=0
............................................................

Analyze critical Chain for a service

To analyze critical chain for a services, use the following command as shown below –

$ sudo systemd-analyze critical-chain bluetooth.service

The sample output should be like this –

The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.

bluetooth.service +886ms

List of dependecies

To get the list of dependecies, use the following command as shown below –

$ sudo systemctl list-dependencies bluetooth.service

List units of a particular type

To get the list units of a particular type, use the following command as shown below –

systemctl -t mount

The sample output should be like this –

UNIT                           LOAD                ACTIVE          SUB                DESCRIPTION
-.mount                        loaded             active          mounted                /
boot-efi.mount                 loaded             active          mounted                /boot/efi
dev-hugepages.mount            loaded             active          mounted                Huge Pages File System
dev-mqueue.mount               loaded             active          mounted                POSIX Message Queue File System
proc-sys-fs-binfmt_misc.mount  loaded             active          mounted                Arbitrary Executable File Formats File Syste
run-user-1000-gvfs.mount       loaded             active          mounted                /run/user/1000/gvfs
run-user-1000.mount            loaded             active          mounted                /run/user/1000
run-user-126.mount             loaded             active          mounted                /run/user/126
sys-fs-fuse-connections.mount  loaded             active          mounted                FUSE Control File System
sys-kernel-debug.mount         loaded             active          mounted                Debug File System
....................................................................

All Loaded Units

To show all loaded units/properties, including dead/empty, use the following command as shown below –

$ systemctl -a

The sample output should be like this –

UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Forma
● org.freedesktop.network1.busname not-found inactive dead org.freedesktop.network1.busnam
dev-cdrom.device loaded active plugged HL-DT-ST_DVD+_-RW_GU90N
dev-cdrw.device loaded active plugged HL-DT-ST_DVD+_-RW_GU90N
dev-disk-by\x2did-ata\x2dHL\x2dDT\x2dST_DVD\x2b_\x2dRW_GU90N_M7FE9H30316.device loaded acti
dev-disk-by\x2did-ata\x2dTOSHIBA_MQ01ABD100_X4P6SQD0S.device loaded active plugged TOSH
dev-disk-by\x2did-ata\x2dTOSHIBA_MQ01ABD100_X4P6SQD0S\x2dpart1.device loaded active plugg
dev-disk-by\x2did-ata\x2dTOSHIBA_MQ01ABD100_X4P6SQD0S\x2dpart2.device loaded active plugg
dev-disk-by\x2did-ata\x2dTOSHIBA_MQ01ABD100_X4P6SQD0S\x2dpart3.device loaded active plugg
dev-disk-by\x2did-wwn\x2d0x50000395d5887d4c.device loaded active plugged TOSHIBA_MQ01AB
dev-disk-by\x2did-wwn\x2d0x50000395d5887d4c\x2dpart1.device loaded active plugged TOSHI
dev-disk-by\x2did-wwn\x2d0x50000395d5887d4c\x2dpart2.device loaded active plugged TOSHI
dev-disk-by\x2did-wwn\x2d0x50000395d5887d4c\x2dpart3.device loaded active plugged TOSHI
dev-disk-by\x2did-wwn\x2d0x5001480000000000.device loaded active plugged HL-DT-ST_DV
..............................................................................................

List of unit files

To get the list of unit files, use the following command as shown below –

$ systemctl list-unit-files

The sample output should be like this –

UNIT FILE                                   STATE
proc-sys-fs-binfmt_misc.automount           static
dev-hugepages.mount                         static
dev-mqueue.mount                            static
proc-sys-fs-binfmt_misc.mount               static
sys-fs-fuse-connections.mount               static
sys-kernel-config.mount                     static
sys-kernel-debug.mount                      static
acpid.path                                  enabled
cups.path                                   enabled
systemd-ask-password-console.path           static
systemd-ask-password-plymouth.path          static
systemd-ask-password-wall.path              static
systemd-networkd-resolvconf-update.path     static
accounts-daemon.service                     enabled
acpid.service                               disabled
alsa-restore.service                        static
alsa-state.service                          static
alsa-utils.service                          masked
anacron-resume.service                      enabled
anacron.service                             enabled
.................................................

List of specified unit files

To get the list of specified unit files, use the following command as shown below –

$ sudo systemctl list-unit-files --type=moun

The sample output should be like this –

UNIT FILE                              STATE
dev-hugepages.mount                    static
dev-mqueue.mount                       static
proc-sys-fs-binfmt_misc.mount          static
sys-fs-fuse-connections.mount          static
sys-kernel-config.mount                static
sys-kernel-debug.mount                 static

6 unit files listed.
......................................................

Unit list of Host and Local Containers

To show unit list of host and local containers, use the following command as shown below –

$ sudo systemctl -r

The sample output should be like this –

UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Formats F
sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2deDP\x2d1-intel_backlight.device loaded
sys-devices-pci0000:00-0000:00:03.0-sound-card0.device loaded active plugged Haswell-ULT HD
sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device loaded active plugged 8 Series HD Aud
sys-devices-pci0000:00-0000:00:1c.2-0000:06:00.0-net-wlp6s0.device loaded active plugged QCA
sys-devices-pci0000:00-0000:00:1c.3-0000:07:00.0-net-enp7s0.device loaded active plugged RTL
sys-devices-pci0000:00-0000:00:1d.0-usb1-1\x2d1-1\x2d1.6-1\x2d1.6:1.0-bluetooth-hci0.device lo
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda3.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded act
sys-devices-pci0000:00-0000:00:1f.2-ata2-host1-target1:0:0-1:0:0:0-block-sr0.device loaded act
sys-devices-platform-dell\x2dlaptop-leds-dell::kbd_backlight.device loaded active plugged
............................................................................................

Queued Jobs

To specify how to deal with already queued jobs, when queueing a new job, use the following command as shown below –

$ systemctl --job-mode=active

The sample output should be like this –

UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Formats F
sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2deDP\x2d1-intel_backlight.device loaded
sys-devices-pci0000:00-0000:00:03.0-sound-card0.device loaded active plugged Haswell-ULT HD
sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device loaded active plugged 8 Series HD Aud
sys-devices-pci0000:00-0000:00:1c.2-0000:06:00.0-net-wlp6s0.device loaded active plugged QCA
sys-devices-pci0000:00-0000:00:1c.3-0000:07:00.0-net-enp7s0.device loaded active plugged RTL
sys-devices-pci0000:00-0000:00:1d.0-usb1-1\x2d1-1\x2d1.6-1\x2d1.6:1.0-bluetooth-hci0.device lo
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda3.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded act
sys-devices-pci0000:00-0000:00:1f.2-ata2-host1-target1:0:0-1:0:0:0-block-sr0.device loaded act
sys-devices-platform-dell\x2dlaptop-leds-dell::kbd_backlight.device loaded active plugged /s
sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform
sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform
sys-devices-platform-serial8250-tty-ttyS10.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS11.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS12.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS13.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS14.device loaded active plugged /sys/devices/plat
..............................................................................................

Socket Types

To get the all socket types, use the following command as shown below –

$ systemctl --show-types

The sample output should be like this –

UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Formats F
sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2deDP\x2d1-intel_backlight.device loaded
sys-devices-pci0000:00-0000:00:03.0-sound-card0.device loaded active plugged Haswell-ULT HD
sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device loaded active plugged 8 Series HD Aud
sys-devices-pci0000:00-0000:00:1c.2-0000:06:00.0-net-wlp6s0.device loaded active plugged QCA
sys-devices-pci0000:00-0000:00:1c.3-0000:07:00.0-net-enp7s0.device loaded active plugged RTL
sys-devices-pci0000:00-0000:00:1d.0-usb1-1\x2d1-1\x2d1.6-1\x2d1.6:1.0-bluetooth-hci0.device lo
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda3.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded act
sys-devices-pci0000:00-0000:00:1f.2-ata2-host1-target1:0:0-1:0:0:0-block-sr0.device loaded act
sys-devices-platform-dell\x2dlaptop-leds-dell::kbd_backlight.device loaded active plugged /s
sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform
sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platf
........................................................................................

Ignore inhibitors

To ignore inhibitors, when shutting down or sleeping. Use the following command as shown below –

$ systemctl -i

The sample output should be like this –

UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Formats F
sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2deDP\x2d1-intel_backlight.device loaded
sys-devices-pci0000:00-0000:00:03.0-sound-card0.device loaded active plugged Haswell-ULT HD
sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device loaded active plugged 8 Series HD Aud
sys-devices-pci0000:00-0000:00:1c.2-0000:06:00.0-net-wlp6s0.device loaded active plugged QCA
sys-devices-pci0000:00-0000:00:1c.3-0000:07:00.0-net-enp7s0.device loaded active plugged RTL
sys-devices-pci0000:00-0000:00:1d.0-usb1-1\x2d1-1\x2d1.6-1\x2d1.6:1.0-bluetooth-hci0.device lo
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda3.device loade
sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded act
sys-devices-pci0000:00-0000:00:1f.2-ata2-host1-target1:0:0-1:0:0:0-block-sr0.device loaded act
sys-devices-platform-dell\x2dlaptop-leds-dell::kbd_backlight.device loaded active plugged /s
sys-devices-platform-serial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform
sys-devices-platform-serial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform
sys-devices-platform-serial8250-tty-ttyS10.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS11.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS12.device loaded active plugged /sys/devices/platfor
sys-devices-platform-serial8250-tty-ttyS13.device loaded active plugged /sys/devices/plat
............................................................................................

List of Socket information

To get the list of socket information, use the following command as shown below

$sudo systemctl list-unit-files --type=socket

The sample output should be like this –

UNIT FILE                     STATE
acpid.socket                  enabled
apport-forward.socket         enabled
avahi-daemon.socket           enabled
cups.socket                   enabled
dbus.socket                   static
saned.socket                  disabled
snapd.socket                  enabled
syslog.socket                 static
systemd-bus-proxyd.socket     static
systemd-fsckd.socket          static
systemd-initctl.socket        static
........................................................................

Enable the Socket

To enable the socket, use the following command as shown below –

$ sudo systemctl start saned.socket

In the above command saned.socket is unit file.

Stop The socket

To stop the socket, use the following command as shown below –

$ sudo systemctl stop saned.socket

Restart The socket

To restart the socket, use the following command as shown below –

$ sudo systemctl restart saned.socket

Reload the socket

To reload the socket, use the following command as shown below –

$ sudo systemctl reload saned.socket

Enable the socket

To enable the socket, use the following command as shown below –

$ sudo systemctl enable saned.socket

Disable The socket

To disable the socket, use the following command as shown below –

$ sudo systemctl disable saned.socket

Mask the socket

To mask the socket, use the following command as shown below –

$ sudo systemctl mask saned.socket

Unmask the Socket

To unmask the socket, use the following command as shown below –

$ sudo systemctl unmask saned.socket

Status of the socket

To get the status of socket, use the following command as shown below –

$ sudo systemctl status saned.socket

The sample output should be like this –

saned.socket - saned incoming socket
   Loaded: loaded (/lib/systemd/system/saned.socket; disabled; vendor preset: enabled)
   Active: active (listening) since Mon 2017-01-30 12:30:05 IST; 2min 59s ago
   Listen: [::]:6566 (Stream)
Accepted: 0; Connected: 0

Jan 30 12:30:05 linux-Inspiron-3542 systemd[1]: Listening on saned incoming socket.

Reboot The system

To reboot the system, use the following command as shown below –

$sudo systemctl reboot

Suspend the system

To suspend the system, use the following command as shown below –

$sudo systemctl suspend

Hibernate The system

To hibernate the system, use the following command as shown below –

$sudo systemctl hibernate

Switch off The system

To switch off the system, use the following command as shown below –

$ sudo systemctl poweroff

Shutdown The system

To shutdown the system, use the following command as shown below –

$sudo systemctl halt

In this article, we have learnt about – Learn modern service management system (Systemd) on Linux, we will come up with more Linux based tricks and tips. Keep reading!

raja
Published on 23-Jan-2020 11:08:40
Advertisements