05-19-2016, 09:48 AM
Source - https://www.linux.com/learn/cleaning-you...up-process
Show which services are taking the longest to start up.
List enabled boot services:
Stop a service (needs both the stop and disable flag)
eg. If you don't have or need Bluetooth:
Confirm the service has been stopped:
A disabled service can be started by another service. If you really want it dead, without uninstalling it, then you can mask it to prevent it from starting under any circumstances:
Generate a list of all services:
Poweroff:
Restart:
Creating a very basic systemd service file:
Start the service.
Show which services are taking the longest to start up.
Code:
jerry[member=2]Jerry[/member]-VirtualBox:~$ systemd-analyze blame
          5.260s NetworkManager-wait-online.service
           725ms nmbd.service
           645ms samba-ad-dc.service
           635ms lvm2-monitor.service
           623ms dev-sda1.device
           492ms ufw.service
           420ms ModemManager.service
           411ms smbd.service
           393ms systemd-logind.service
           391ms accounts-daemon.service
           327ms networking.service
           253ms NetworkManager.service
           250ms virtualbox-guest-utils.service
           229ms ondemand.service
           228ms apparmor.service
           207ms irqbalance.service
           183ms grub-common.service
           177ms lightdm.service
           166ms lm-sensors.service
           158ms console-kit-log-system-start.service
           134ms gpu-manager.service
           117ms udisks2.service
           110ms systemd-udev-trigger.service
           108ms thermald.service
            97ms console-kit-daemon.service
            94ms console-setup.service
            92ms systemd-udevd.service
            90ms avahi-daemon.service
            90ms upower.service
            84ms systemd-modules-load.service
            72ms plymouth-start.service
            62ms rsyslog.service
            54ms systemd-journald.service
            52ms [email protected]
            51ms polkitd.service
            46ms systemd-tmpfiles-setup.service
            43ms ubiquity.service
            36ms systemd-tmpfiles-setup-dev.service
            36ms hddtemp.service
            33ms systemd-update-utmp.service
            25ms systemd-journal-flush.service
            23ms pppd-dns.service
            23ms systemd-hostnamed.service
            20ms systemd-user-sessions.service
            19ms dev-hugepages.mount
            19ms dns-clean.service
            18ms rtkit-daemon.service
            18ms plymouth-read-write.service
            17ms sys-kernel-debug.mount
            17ms dev-disk-by\x2duuid-0994cbe3\x2df958\x2d4b7d\x2d9fd4\x2d4f9149dcf127.swap
            15ms kmod-static-nodes.service
            14ms systemd-sysctl.service
            14ms resolvconf.service
            12ms systemd-update-utmp-runlevel.service
            10ms systemd-remount-fs.service
            10ms dev-mqueue.mount
             8ms sys-fs-fuse-connections.mount
             7ms systemd-random-seed.service
             5ms openvpn.service
             3ms rc-local.service
             2ms plymouth-quit-wait.serviceCode:
jerry[member=2]Jerry[/member]-VirtualBox:~$ systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.
graphical.target @10.148s
└─lightdm.service @7.019s +3.127s
  └─systemd-user-sessions.service @7.002s +12ms
    └─network.target @6.990s
      └─networking.service @3.023s +3.966s
        └─apparmor.service @2.901s +107ms
          └─local-fs.target @2.899s
            └─zfs-mount.service @2.883s +15ms
              └─zfs-import.target @2.882sList enabled boot services:
Code:
jerry[member=2]Jerry[/member]-VirtualBox:~$ systemctl list-unit-files --type=service | grep enabled
accounts-daemon.service                    enabled 
[email protected]                            enabled 
avahi-daemon.service                       enabled 
bluetooth.service                          enabled 
casper.service                             enabled 
cgmanager.service                          enabled 
cgproxy.service                            enabled 
cron.service                               enabled 
cups-browsed.service                       enabled 
cups.service                               enabled 
dbus-org.bluez.service                     enabled 
dbus-org.freedesktop.Avahi.service         enabled 
dbus-org.freedesktop.ModemManager1.service enabled 
dbus-org.freedesktop.nm-dispatcher.service enabled 
dbus-org.freedesktop.thermald.service      enabled 
display-manager.service                    enabled 
dns-clean.service                          enabled 
friendly-recovery.service                  enabled 
[email protected]                             enabled 
gpu-manager.service                        enabled 
lightdm.service                            enabled 
lm-sensors.service                         enabled 
lvm2-monitor.service                       enabled 
ModemManager.service                       enabled 
network-manager.service                    enabled 
networking.service                         enabled 
NetworkManager-dispatcher.service          enabled 
NetworkManager-wait-online.service         enabled 
NetworkManager.service                     enabled 
openvpn.service                            enabled 
pppd-dns.service                           enabled 
resolvconf.service                         enabled 
rsyslog.service                            enabled 
syslog.service                             enabled 
systemd-timesyncd.service                  enabled 
thermald.service                           enabled 
ubiquity.service                           enabled 
ufw.service                                enabled 
unattended-upgrades.service                enabled 
ureadahead.service                         enabled 
jerry[member=2]Jerry[/member]-VirtualBox:~$Stop a service (needs both the stop and disable flag)
eg. If you don't have or need Bluetooth:
Code:
sudo systemctl stop bluetooth.service
sudo systemctl disable bluetooth.serviceConfirm the service has been stopped:
Code:
jerry[member=2]Jerry[/member]-VirtualBox:~$ systemctl status bluetooth.service
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:bluetoothd(
May 19 21:33:04 jerry-VirtualBox systemd[1]: Stopped Bluetooth service.
jerry[member=2]Jerry[/member]-VirtualBox:~$A disabled service can be started by another service. If you really want it dead, without uninstalling it, then you can mask it to prevent it from starting under any circumstances:
Code:
jerry[member=2]Jerry[/member]-VirtualBox:~$ sudo systemctl mask bluetooth.service
Created symlink from /etc/systemd/system/bluetooth.service to /dev/null.
jerry[member=2]Jerry[/member]-VirtualBox:~$Generate a list of all services:
Code:
jerry[member=2]Jerry[/member]-VirtualBox:~$ systemctl list-unit-files --type=service
UNIT FILE                                  STATE   
accounts-daemon.service                    enabled 
acpid.service                              disabled
alsa-restore.service                       static  
alsa-state.service                         static  
alsa-utils.service                         masked  
apt-daily.service                          static  
[email protected]                            enabled 
avahi-daemon.service                       enabled 
bluetooth.service                          masked  
bootlogd.service                           masked  
bootlogs.service                           masked  
bootmisc.service                           masked  
casper.service                             enabled 
cgmanager.service                          enabled 
cgproxy.service                            enabled 
checkfs.service                            masked  
checkroot-bootclean.service                masked  
checkroot.service                          masked  
colord.service                             static  
console-getty.service                      disabled
console-kit-daemon.service                 disabled
console-kit-log-system-restart.service     static  
console-kit-log-system-start.service       static  
console-kit-log-system-stop.service        static  
console-setup.service                      static  
console-shell.service                      disabled
[email protected]                   static  
cron.service                               enabled 
cryptdisks-early.service                   masked  
cryptdisks.service                         masked  
cups-browsed.service                       enabled 
cups.service                               enabled 
dbus-org.freedesktop.Avahi.service         enabled 
dbus-org.freedesktop.hostname1.service     static  
dbus-org.freedesktop.locale1.service       static  
dbus-org.freedesktop.login1.service        static  
dbus-org.freedesktop.ModemManager1.service enabled 
dbus-org.freedesktop.network1.service      disabled
dbus-org.freedesktop.nm-dispatcher.service enabled 
dbus-org.freedesktop.resolve1.service      disabled
dbus-org.freedesktop.thermald.service      enabled 
dbus-org.freedesktop.timedate1.service     static  
dbus.service                               static  
debug-shell.service                        disabled
display-manager.service                    enabled 
dm-event.service                           disabled
dns-clean.service                          enabled 
emergency.service                          static  
friendly-recovery.service                  enabled 
fuse.service                               masked  
getty-static.service                       static  
[email protected]                             enabled 
gpu-manager.service                        enabled 
halt.service                               masked  
hostname.service                           masked  
hwclock.service                            masked  
[email protected]                              static  
initrd-cleanup.service                     static  
initrd-parse-etc.service                   static  
initrd-switch-root.service                 static  
initrd-udevadm-cleanup-db.service          static  
killprocs.service                          masked  
kmod-static-nodes.service                  static  
kmod.service                               static  
lightdm.service                            enabled 
lm-sensors.service                         enabled 
lvm2-lvmetad.service                       disabled
lvm2-lvmpolld.service                      disabled
lvm2-monitor.service                       enabled 
[email protected]                       static  
lvm2.service                               masked  
ModemManager.service                       enabled 
module-init-tools.service                  static  
motd.service                               masked  
mountall-bootclean.service                 masked  
mountall.service                           masked  
mountdevsubfs.service                      masked  
mountkernfs.service                        masked  
mountnfs-bootclean.service                 masked  
mountnfs.service                           masked  
network-manager.service                    enabled 
networking.service                         enabled 
NetworkManager-dispatcher.service          enabled 
NetworkManager-wait-online.service         enabled 
NetworkManager.service                     enabled 
openvpn.service                            enabled 
[email protected]                           disabled
plymouth-halt.service                      static  
plymouth-kexec.service                     static  
plymouth-log.service                       static  
plymouth-poweroff.service                  static  
plymouth-quit-wait.service                 static  
plymouth-quit.service                      static  
plymouth-read-write.service                static  
plymouth-reboot.service                    static  
plymouth-start.service                     static  
plymouth-switch-root.service               static  
plymouth.service                           static  
polkitd.service                            static  
pppd-dns.service                           enabled 
procps.service                             static  
quotaon.service                            static  
rc-local.service                           static  
rc.local.service                           static  
rc.service                                 masked  
rcS.service                                masked  
reboot.service                             masked  
rescue.service                             static  
resolvconf.service                         enabled 
rmnologin.service                          masked  
rsync.service                              disabled
rsyslog.service                            enabled 
rtkit-daemon.service                       disabled
samba.service                              masked  
saned.service                              masked  
[email protected]                             indirect
sendsigs.service                           masked  
[email protected]                      disabled
sigpwr-container-shutdown.service          static  
single.service                             masked  
stop-bootlogd-single.service               masked  
stop-bootlogd.service                      masked  
syslog.service                             enabled 
systemd-ask-password-console.service       static  
systemd-ask-password-plymouth.service      static  
systemd-ask-password-wall.service          static  
[email protected]                 static  
systemd-binfmt.service                     static  
systemd-bootchart.service                  disabled
systemd-bus-proxyd.service                 static  
systemd-exit.service                       static  
systemd-fsck-root.service                  static  
[email protected]                      static  
systemd-fsckd.service                      static  
systemd-halt.service                       static  
[email protected]          static  
systemd-hibernate.service                  static  
systemd-hostnamed.service                  static  
systemd-hwdb-update.service                static  
systemd-hybrid-sleep.service               static  
systemd-initctl.service                    static  
systemd-journal-flush.service              static  
systemd-journald.service                   static  
systemd-kexec.service                      static  
systemd-localed.service                    static  
systemd-logind.service                     static  
systemd-machine-id-commit.service          static  
systemd-modules-load.service               static  
systemd-networkd-resolvconf-update.service static  
systemd-networkd-wait-online.service       disabled
systemd-networkd.service                   disabled
systemd-poweroff.service                   static  
systemd-quotacheck.service                 static  
systemd-random-seed.service                static  
systemd-reboot.service                     static  
systemd-remount-fs.service                 static  
systemd-resolved.service                   disabled
systemd-rfkill.service                     static  
systemd-suspend.service                    static  
systemd-sysctl.service                     static  
systemd-timedated.service                  static  
systemd-timesyncd.service                  enabled 
systemd-tmpfiles-clean.service             static  
systemd-tmpfiles-setup-dev.service         static  
systemd-tmpfiles-setup.service             static  
systemd-udev-settle.service                static  
systemd-udev-trigger.service               static  
systemd-udevd.service                      static  
systemd-update-utmp-runlevel.service       static  
systemd-update-utmp.service                static  
systemd-user-sessions.service              static  
thermald.service                           enabled 
ubiquity.service                           enabled 
[email protected]            static  
udev.service                               static  
udisks2.service                            disabled
ufw.service                                enabled 
umountfs.service                           masked  
umountnfs.service                          masked  
umountroot.service                         masked  
unattended-upgrades.service                enabled 
upower.service                             disabled
urandom.service                            static  
ureadahead-stop.service                    static  
ureadahead.service                         enabled 
[email protected]                    static  
usbmuxd.service                            static  
[email protected]                              static  
uuidd.service                              indirect
[email protected]                 static  
wpa_supplicant.service                     disabled
x11-common.service                         masked  
192 unit files listed.Poweroff:
Code:
sudo systemctl poweroffRestart:
Code:
sudo systemctl rebootCreating a very basic systemd service file:
Code:
sudo touch /lib/systemd/system/myservicename.serviceCode:
sudo nano /lib/systemd/system/myservicename.serviceCode:
[Unit]
Description=A brief description of my application
# Wants - other service required to run this service
Wants=network.target
# After - start my service after this service
After=network.target
[Service]
User=jerry
RemainAfterExit=yes
ExecStart=/usr/bin/myapplication
Restart=on-failure
[Install]
WantedBy=multi-user.targetStart the service.
Code:
sudo systemctl daemon-reloadCode:
sudo systemctl start myservicename.service 
 ![[Image: BSzW1pW.png]](http://i.imgur.com/BSzW1pW.png)
![[Image: O2eJMcd.png]](http://i.imgur.com/O2eJMcd.png)