{"id":1158,"date":"2026-07-16T09:49:34","date_gmt":"2026-07-16T06:49:34","guid":{"rendered":"https:\/\/itgen.itbumper.com\/?page_id=1158"},"modified":"2026-07-16T11:01:01","modified_gmt":"2026-07-16T08:01:01","slug":"0046_mobaxterm-macros-04-debian-services-systemd","status":"publish","type":"page","link":"https:\/\/itgen.itbumper.com\/?page_id=1158","title":{"rendered":"0046_MobaXterm macros: 04.Debian-Services &amp; Systemd"},"content":{"rendered":"\n<p>4.1 System State (+ Default Target &amp; Status)<br>4.2 Failed Units<br>4.3 Failed Unit Details (Status &amp; Logs loop)<br>4.4 Running Services<br>4.5 Enabled Services<br>4.6 Disabled Services<br>4.7 Masked Units<br>4.8 Systemd Jobs<br>4.9 Boot Critical Chain<br>4.10 Long-running Startup Units (Blame)<br>4.11 Systemd Timers<br>4.12 Recent System Errors (Journalctl -p err)<br>4.13 Recent Service Restart Activity<\/p>\n<p><strong>Copy&#8211;&gt;Past<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\necho &quot;==================== 04. SERVICES &amp; SYSTEMD ====================&quot;; printf &quot;\\n&quot;; echo &quot;4.1 SYSTEM STATE&quot;; echo &quot;--- Overall State ---&quot;; systemctl is-system-running 2&gt;\/dev\/null || echo &quot;System state check unavailable&quot;; printf &quot;\\n&quot;; echo &quot;--- Default Target ---&quot;; systemctl get-default 2&gt;\/dev\/null || echo &quot;Default target unavailable&quot;; printf &quot;\\n&quot;; echo &quot;--- System Status ---&quot;; systemctl status --no-pager 2&gt;\/dev\/null | head -50 || echo &quot;Global systemd status unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.2 FAILED UNITS&quot;; systemctl --failed --all --no-pager 2&gt;\/dev\/null || echo &quot;Failed unit tracking unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.3 FAILED UNIT DETAILS&quot;; FAILED_UNITS=$(systemctl --failed --type=service --no-legend --plain 2&gt;\/dev\/null | awk '{print $1}'); if &#x5B; -n &quot;$FAILED_UNITS&quot; ]; then for UNIT in $FAILED_UNITS; do echo &quot;--- $UNIT ---&quot;; systemctl status &quot;$UNIT&quot; --no-pager --full 2&gt;\/dev\/null | head -40; printf &quot;\\n&quot;; journalctl -u &quot;$UNIT&quot; -b -n 30 --no-pager 2&gt;\/dev\/null; printf &quot;\\n&quot;; done; else echo &quot;No failed service units&quot;; fi; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.4 RUNNING SERVICES&quot;; systemctl list-units --type=service --state=running --no-pager --no-legend 2&gt;\/dev\/null | head -80 || echo &quot;Running services listing unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.5 ENABLED SERVICES&quot;; systemctl list-unit-files --type=service --state=enabled --no-pager --no-legend 2&gt;\/dev\/null | head -80 || echo &quot;Enabled service listing unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.6 DISABLED SERVICES&quot;; systemctl list-unit-files --type=service --state=disabled --no-pager --no-legend 2&gt;\/dev\/null | head -80 || echo &quot;Disabled service listing unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.7 MASKED UNITS&quot;; systemctl list-unit-files --state=masked --no-pager 2&gt;\/dev\/null || echo &quot;Masked unit listing unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.8 SYSTEMD JOBS&quot;; systemctl list-jobs --no-pager 2&gt;\/dev\/null || echo &quot;No pending systemd jobs or listing unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.9 BOOT CRITICAL CHAIN&quot;; if command -v systemd-analyze &gt;\/dev\/null 2&gt;&amp;1; then systemd-analyze critical-chain --no-pager 2&gt;\/dev\/null | head -50; else echo &quot;systemd-analyze not installed&quot;; fi; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.10 LONG-RUNNING STARTUP UNITS&quot;; if command -v systemd-analyze &gt;\/dev\/null 2&gt;&amp;1; then systemd-analyze blame 2&gt;\/dev\/null | head -30; else echo &quot;systemd-analyze not installed&quot;; fi; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.11 SYSTEMD TIMERS&quot;; systemctl list-timers --all --no-pager 2&gt;\/dev\/null || echo &quot;Systemd timer listing unavailable&quot;; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.12 RECENT SYSTEM ERRORS&quot;; if command -v journalctl &gt;\/dev\/null 2&gt;&amp;1; then journalctl -p err -b --no-pager 2&gt;\/dev\/null | tail -n 50; else echo &quot;journalctl not available&quot;; fi; printf &quot;\\n%.0s&quot; {1..3}; echo &quot;4.13 RECENT SERVICE RESTART ACTIVITY&quot;; if command -v journalctl &gt;\/dev\/null 2&gt;&amp;1; then journalctl -b --no-pager 2&gt;\/dev\/null | grep -Ei 'Started |Stopped |Starting |Stopping |Failed to start|Main process exited|Scheduled restart job' | tail -n 80 || echo &quot;No recent service restart activity found&quot;; else echo &quot;journalctl not available&quot;; fi\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# ==================== 04. SERVICES &amp; SYSTEMD ====================\necho &quot;==================== 04. SERVICES &amp; SYSTEMD ====================&quot;\nprintf &quot;\\n&quot;\n\n# --- 4.1 SYSTEM STATE ---\necho &quot;4.1 SYSTEM STATE&quot;\necho &quot;--- Overall State ---&quot;\nsystemctl is-system-running 2&gt;\/dev\/null || echo &quot;System state check unavailable&quot;\nprintf &quot;\\n&quot;\necho &quot;--- Default Target ---&quot;\nsystemctl get-default 2&gt;\/dev\/null || echo &quot;Default target unavailable&quot;\nprintf &quot;\\n&quot;\necho &quot;--- System Status ---&quot;\nsystemctl status --no-pager 2&gt;\/dev\/null | head -50 || echo &quot;Global systemd status unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.2 FAILED UNITS ---\necho &quot;4.2 FAILED UNITS&quot;\nsystemctl --failed --all --no-pager 2&gt;\/dev\/null || echo &quot;Failed unit tracking unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.3 FAILED UNIT DETAILS ---\necho &quot;4.3 FAILED UNIT DETAILS&quot;\nFAILED_UNITS=$(systemctl --failed --type=service --no-legend --plain 2&gt;\/dev\/null | awk '{print $1}')\nif &#x5B; -n &quot;$FAILED_UNITS&quot; ]; then\n    for UNIT in $FAILED_UNITS; do\n        echo &quot;--- $UNIT ---&quot;\n        systemctl status &quot;$UNIT&quot; --no-pager --full 2&gt;\/dev\/null | head -40\n        printf &quot;\\n&quot;\n        journalctl -u &quot;$UNIT&quot; -b -n 30 --no-pager 2&gt;\/dev\/null\n        printf &quot;\\n&quot;\n    done\nelse\n    echo &quot;No failed service units&quot;\nfi\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.4 RUNNING SERVICES ---\necho &quot;4.4 RUNNING SERVICES&quot;\nsystemctl list-units --type=service --state=running --no-pager --no-legend 2&gt;\/dev\/null | head -80 || \\\n    echo &quot;Running services listing unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.5 ENABLED SERVICES ---\necho &quot;4.5 ENABLED SERVICES&quot;\nsystemctl list-unit-files --type=service --state=enabled --no-pager --no-legend 2&gt;\/dev\/null | head -80 || \\\n    echo &quot;Enabled service listing unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.6 DISABLED SERVICES ---\necho &quot;4.6 DISABLED SERVICES&quot;\nsystemctl list-unit-files --type=service --state=disabled --no-pager --no-legend 2&gt;\/dev\/null | head -80 || \\\n    echo &quot;Disabled service listing unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.7 MASKED UNITS ---\necho &quot;4.7 MASKED UNITS&quot;\nsystemctl list-unit-files --state=masked --no-pager 2&gt;\/dev\/null || \\\n    echo &quot;Masked unit listing unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.8 SYSTEMD JOBS ---\necho &quot;4.8 SYSTEMD JOBS&quot;\nsystemctl list-jobs --no-pager 2&gt;\/dev\/null || echo &quot;No pending systemd jobs or listing unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.9 BOOT CRITICAL CHAIN ---\necho &quot;4.9 BOOT CRITICAL CHAIN&quot;\nif command -v systemd-analyze &gt;\/dev\/null 2&gt;&amp;1; then\n    systemd-analyze critical-chain --no-pager 2&gt;\/dev\/null | head -50\nelse\n    echo &quot;systemd-analyze not installed&quot;\nfi\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.10 LONG-RUNNING STARTUP UNITS ---\necho &quot;4.10 LONG-RUNNING STARTUP UNITS&quot;\nif command -v systemd-analyze &gt;\/dev\/null 2&gt;&amp;1; then\n    systemd-analyze blame 2&gt;\/dev\/null | head -30\nelse\n    echo &quot;systemd-analyze not installed&quot;\nfi\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.11 SYSTEMD TIMERS ---\necho &quot;4.11 SYSTEMD TIMERS&quot;\nsystemctl list-timers --all --no-pager 2&gt;\/dev\/null || echo &quot;Systemd timer listing unavailable&quot;\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.12 RECENT SYSTEM ERRORS ---\necho &quot;4.12 RECENT SYSTEM ERRORS&quot;\nif command -v journalctl &gt;\/dev\/null 2&gt;&amp;1; then\n    journalctl -p err -b --no-pager 2&gt;\/dev\/null | tail -n 50\nelse\n    echo &quot;journalctl not available&quot;\nfi\nprintf &quot;\\n%.0s&quot; {1..3}\n\n# --- 4.13 RECENT SERVICE RESTART ACTIVITY ---\necho &quot;4.13 RECENT SERVICE RESTART ACTIVITY&quot;\nif command -v journalctl &gt;\/dev\/null 2&gt;&amp;1; then\n    journalctl -b --no-pager 2&gt;\/dev\/null | grep -Ei 'Started |Stopped |Starting |Stopping |Failed to start|Main process exited|Scheduled restart job' | tail -n 80 || \\\n        echo &quot;No recent service restart activity found&quot;\nelse\n    echo &quot;journalctl not available&quot;\nfi\n<\/pre><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"883\" height=\"1024\" src=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-01-883x1024.png\" alt=\"\" class=\"wp-image-1165\" style=\"width:800px\" srcset=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-01-883x1024.png 883w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-01-259x300.png 259w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-01-768x890.png 768w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-01.png 903w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"877\" height=\"1024\" src=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-02-877x1024.png\" alt=\"\" class=\"wp-image-1166\" style=\"width:796px\" srcset=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-02-877x1024.png 877w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-02-257x300.png 257w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-02-768x896.png 768w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-02.png 1071w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"1024\" src=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-03-709x1024.png\" alt=\"\" class=\"wp-image-1168\" style=\"width:800px\" srcset=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-03-709x1024.png 709w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-03-208x300.png 208w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-03-768x1109.png 768w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-03.png 870w\" sizes=\"(max-width: 709px) 85vw, 709px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"852\" src=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-04-1024x852.png\" alt=\"\" class=\"wp-image-1169\" style=\"width:800px\" srcset=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-04-1024x852.png 1024w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-04-300x249.png 300w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-04-768x639.png 768w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-04.png 1122w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"446\" src=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-05-1024x446.png\" alt=\"\" class=\"wp-image-1170\" style=\"width:797px\" srcset=\"https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-05-1024x446.png 1024w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-05-300x131.png 300w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-05-768x335.png 768w, https:\/\/itgen.itbumper.com\/wp-content\/uploads\/2026\/07\/004_debian_services_systemd-05.png 1058w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure><\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[21,26],"tags":[],"_links":{"self":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages\/1158"}],"collection":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1158"}],"version-history":[{"count":4,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages\/1158\/revisions"}],"predecessor-version":[{"id":1171,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages\/1158\/revisions\/1171"}],"wp:attachment":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}