{"id":1590,"date":"2021-12-16T12:35:26","date_gmt":"2021-12-16T09:35:26","guid":{"rendered":"https:\/\/files2.tojikon.net\/files-cloud\/2021\/04\/23\/linux-how-to-use-systemd-to-list-services\/https:\/\/files2.tojikon.net\/files-cloud\/2021\/04\/23\/linux-how-to-use-systemd-to-list-services\/"},"modified":"2021-12-16T12:35:26","modified_gmt":"2021-12-16T09:35:26","slug":"linux-how-to-use-systemd-to-list-services","status":"publish","type":"post","link":"https:\/\/tojikon.net\/en\/1590-linux-how-to-use-systemd-to-list-services\/","title":{"rendered":"Linux: How to use Systemd to list services"},"content":{"rendered":"<section id=\"related_posts\">\n<div class=\"block-head\">\n<h3>Related Articles<\/h3>\n<\/div>\n<\/section>\n<p>Mainstream Linux distributions all use Systemd, an init system that works based on enabling and disabling \u201cservice\u201d files. If you\u2019re trying to list these service files but don\u2019t know how to do it, you\u2019ll need to make use of the <strong>systemctl\u00a0<\/strong>command.<\/p>\n<p>In this guide, we\u2019ll go over the various way you can list Systemd service files on Linux. To get started, ensure you\u2019re using a Linux OS with Systemd. Then, open up a terminal window and follow along.<\/p>\n<h2>Use Systemd to list active services<\/h2>\n<p>If you\u2019re using Systemd a lot, at some point, you may want to know what services are active while your Linux system is booted. Listing active services is very easy, and you can do it with the <strong>systemctl \u2013type=service systemctl \u2013type=service \u2013state=running<\/strong> command.<\/p>\n<p>This command, when run, will show a table of all services, if they are active, as well as a brief description. To run this program, open up a terminal window. Once the terminal window is open, execute the command below.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-400371 size-full\" src=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services.png\" alt=\"\" width=\"1200\" height=\"628\" srcset=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services.png 1200w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-8.png 300w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-10.png 1024w, https:\/\/www.addictivetips.com\/app\/uploads\/2021\/04\/systemctl-running-fs8-768x402.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"\/><\/p>\n<pre>\nsystemctl --type=service --state=running\n<\/pre>\n<p>If you\u2019re trying to filter through all active services for a particular service, looking through this large table can be pretty tedious. Thankfully, the <strong>systemctl\u00a0<\/strong>command can be combined with the\u00a0<strong>grep\u00a0<\/strong>command as a filtering mechanism.<\/p>\n<p>For example, to check if the \u201csnapd.service\u201d is running and loaded, you can run <strong>systemctl \u2013type=service \u2013state=running | grep \u2018snapd,\u2019<\/strong>\u00a0and the output will only show the Snapd service, instead of the entire table.<\/p>\n<pre>\nsystemctl --type=service --state=running | grep 'snapd'\n<\/pre>\n<p>If you\u2019d like to save the output of the table to a text file for later, use the following command.\u00a0<\/p>\n<pre>\nsystemctl --type=service --state=runningrunning &gt; ~\/active-services.txt\n<\/pre>\n<p>To view the text file at any time, execute the <strong>cat\u00a0<\/strong>command below.<\/p>\n<pre>\ncat ~\/active-services.txt\n<\/pre>\n<h2>Use Systemd to list inactive services<\/h2>\n<p>Listing active Systemd services is helpful, but what about inactive ones? Yes, it is possible to list those as well. Here\u2019s how. First, open up a terminal window.\u00a0<\/p>\n<p>Once the terminal window is open and ready to use, execute the\u00a0<strong>systemctl \u2013type=service\u00a0<\/strong>command but in the\u00a0<strong>\u2013state=\u00a0<\/strong>slot, place \u201cinactive\u201d rather than \u201crunning.\u201d By doing this, you can see what Systemd services are inactive on your Linux system.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-400370 size-full\" src=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-2.png\" alt=\"\" width=\"1200\" height=\"877\" srcset=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-2.png 1200w, https:\/\/www.addictivetips.com\/app\/uploads\/2021\/04\/systemctl-inactive-fs8-300x219.png 300w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-14.png 1024w, https:\/\/www.addictivetips.com\/app\/uploads\/2021\/04\/systemctl-inactive-fs8-768x561.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"\/><\/p>\n<pre>\nsystemctl --type=service --state=inactive\n<\/pre>\n<p>Like with the active services, Systemd will create a nice, neat table and show you what Systemd services are inactive, dead, and not in use. If you\u2019d like to filter through this table to find if a specific service is dead, you can combine it with the <strong>grep\u00a0<\/strong>command.<\/p>\n<p>For example, to determine if the \u201cupdatedb.service\u201d file is inactive, you can combine\u00a0<strong>systemctl \u2013type=service \u2013state=inactive\u00a0<\/strong>with the\u00a0<strong>grep\u00a0<\/strong>command below to search the table for it.<\/p>\n<pre>\nsystemctl --type=service --state=inactive | grep 'updatedb.service'\n<\/pre>\n<p>If you need to save all inactive Systemd service files to a text file for reading later, use the following command.<\/p>\n<pre>\nsystemctl --type=service --state=inactive &gt; ~\/inactive-services.txt\n<\/pre>\n<p>To read this text file right from the terminal window, use the\u00a0<strong>cat\u00a0<\/strong>command.<\/p>\n<pre>\ncat ~\/inactive-services.txt\n<\/pre>\n<h2>Use Systemd to list all installed services\u00a0<\/h2>\n<p>If you need to see all installed Systemd services, whether they\u2019re active or not, you\u2019ll need to use the <strong>systemctl list-unit-files \u2013type=service\u00a0<\/strong>command and exclude the <strong>\u2013state<\/strong> command-line switch. By excluding\u00a0<strong>\u2013state<\/strong>, Systemd will be able to list each and every service file on your computer with ease.\u00a0<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-400369 size-full\" src=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-6.png\" alt=\"\" width=\"1200\" height=\"1376\" srcset=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-6.png 1200w, https:\/\/www.addictivetips.com\/app\/uploads\/2021\/04\/systemctl-all-fs8-262x300.png 262w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-17.png 893w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-18.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"\/><\/p>\n<pre>\nsystemctl list-unit-files --type=service\n<\/pre>\n<p>Once the above command is executed, Systemd will print out a table with every service file on the system. From here, you can sort through the table to find the service file you need.\u00a0<\/p>\n<p>If you cannot find a specific service file, you can combine the <strong>systemctl list-unit-files \u2013type=service\u00a0<\/strong>command with the\u00a0<strong>grep\u00a0<\/strong>command to use a filter. Using the command below, filter the table to find the service file you need.<\/p>\n<pre>\nsystemctl list-unit-files --type=service | grep 'my-service'\n<\/pre>\n<p>Want to export all Systemd services to a text file to read later on? Execute the following command.<\/p>\n<pre>\nsystemctl list-unit-files --type=service &gt; ~\/service-files.txt\n<\/pre>\n<p>You can view the text file at any time with the\u00a0<strong>cat\u00a0<\/strong>command below.<\/p>\n<pre>\ncat ~\/service-files.txt\n<\/pre>\n<h2>Use Systemd to display the status of individual service<\/h2>\n<p>While it is helpful to know how to list all Systemd services, ones that are active and inactive, it\u2019s also useful know how to list the status of services individually. Here\u2019s how to do it.<\/p>\n<p>First, open up a terminal window. Once the terminal window is open, use the\u00a0<strong>systemctl status\u00a0<\/strong>command on a particular service. For example, to find the status of \u201cNetworkManager.service,\u201d the following command is run.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-400372 size-full\" src=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-7.png\" alt=\"\" width=\"1200\" height=\"433\" srcset=\"https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-7.png 1200w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-20.png 300w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-23.png 1024w, https:\/\/files2.tojikon.net\/files-cloud\/wp-content\/uploads\/2021\/12\/linux-how-to-use-systemd-to-list-services-24.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"\/><\/p>\n<pre>\nsystemctl status NetworkManager\n<\/pre>\n<p>If you\u2019d like to export the status command\u2019s output to a text file for later reading, you can enter the command below.\u00a0<\/p>\n<pre>\nsystemctl status MyService &gt; ~\/MyService-status.txt\n<\/pre>\n<p>To view this file, execute the following\u00a0<strong>cat\u00a0<\/strong>command.<\/p>\n<pre>\ncat ~\/MyService-status.txt\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Related Articles Mainstream Linux distributions all use Systemd, an init system that works based on enabling and disabling \u201cservice\u201d files. If you\u2019re trying to list these service files but don\u2019t know how to do it, you\u2019ll need to make use of the systemctl\u00a0command. In this guide, we\u2019ll go over the various way you can list &hellip;<\/p>\n","protected":false},"author":1,"featured_media":1591,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21],"tags":[33],"_links":{"self":[{"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/posts\/1590"}],"collection":[{"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/comments?post=1590"}],"version-history":[{"count":0,"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/posts\/1590\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/media\/1591"}],"wp:attachment":[{"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/media?parent=1590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/categories?post=1590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tojikon.net\/en\/wp-json\/wp\/v2\/tags?post=1590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}