
{"id":30217,"date":"2026-04-24T14:23:22","date_gmt":"2026-04-24T12:23:22","guid":{"rendered":"https:\/\/contabo.com\/blog\/?p=30217"},"modified":"2026-04-24T14:23:26","modified_gmt":"2026-04-24T12:23:26","slug":"list-and-manage-linux-services-with-systemctl","status":"publish","type":"post","link":"https:\/\/contabo.com\/blog\/list-and-manage-linux-services-with-systemctl\/","title":{"rendered":"List and Manage Linux Services with systemctl"},"content":{"rendered":"\n<p>A server with 40 running services and no idea which ones are actually needed is a security incident waiting to happen. systemctl gives you full visibility and control over every daemon on your system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-linux-services-work\">How Linux Services Work<\/h2>\n\n\n\n<p>Linux services are background processes that run independently of user sessions. They handle everything from web serving to cron scheduling to SSH access. On modern Linux systems, they&#8217;re managed by systemd.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-what-is-a-daemon\">What Is a Daemon?<\/h3>\n\n\n\n<p>A daemon is a process that runs in the background, typically starting at boot and running continuously. The name comes from Unix tradition. Apache is a daemon. sshd is a daemon. MySQL is a daemon. They don&#8217;t have a controlling terminal and don&#8217;t require user interaction to run.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-systemd-vs-older-init-systems\">systemd vs Older Init Systems<\/h3>\n\n\n\n<p>systemd replaced SysVinit as the default init system in most major distributions around 2014-2015. The key differences: systemd starts services in parallel (faster boot), uses declarative unit files instead of shell scripts, tracks service dependencies explicitly, and integrates logging via the journal. If you&#8217;re on Ubuntu 16.04+, CentOS 7+, or Debian 8+, you&#8217;re using systemd.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-list-linux-services\">How to List Linux Services<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-list-all-unit-files-with-systemctl\">List All Unit Files with systemctl<\/h3>\n\n\n\n<p>The main command to list services and their states:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl list-unit-files --type=service<\/code><\/pre>\n\n\n\n<p>This outputs every service unit file on the system with its state (enabled, disabled, masked, static, or failed) and its vendor preset default.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-list-only-running-services\">List Only Running Services<\/h3>\n\n\n\n<p>To see only active services:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl list-units --type=service --state=running<\/code><\/pre>\n\n\n\n<p>This is useful when you want to audit what&#8217;s actually running versus what&#8217;s just installed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-filter-services-by-state\">Filter Services by State<\/h3>\n\n\n\n<p>systemctl list services supports filtering by state:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl list-units --type=service --state=failed<\/code><\/pre>\n\n\n\n<p>Failed services are the ones you want to investigate immediately. A service that failed on boot and nobody noticed is a common source of mysterious behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-listing-services-on-older-systems\">Listing Services on Older Systems<\/h3>\n\n\n\n<p>On systems still using SysVinit or that have the service command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>service --status-all<\/code><\/pre>\n\n\n\n<p>The output shows + for running, &#8211; for stopped, and ? for unknown state.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-manage-linux-services\">How to Manage Linux Services<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-start-and-stop-a-service\">Start and Stop a Service<\/h3>\n\n\n\n<p>Start a stopped service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start nginx<\/code><\/pre>\n\n\n\n<p>Stop a running service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl stop nginx<\/code><\/pre>\n\n\n\n<p>These changes are immediate but not persistent. If the server reboots, the service reverts to its enabled\/disabled state.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-restart-and-reload-a-service\">Restart and Reload a Service<\/h3>\n\n\n\n<p>Full restart (stops and starts the process):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nginx<\/code><\/pre>\n\n\n\n<p>Reload configuration without restarting the process (supported by some services):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl reload nginx<\/code><\/pre>\n\n\n\n<p>reload is preferable for services like nginx where a restart briefly drops connections. Not all services support it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-enable-and-disable-at-boot\">Enable and Disable at Boot<\/h3>\n\n\n\n<p>Enable a service to start automatically at boot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable nginx<\/code><\/pre>\n\n\n\n<p>Disable it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl disable nginx<\/code><\/pre>\n\n\n\n<p>Enable and start in one command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable --now nginx<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-check-a-service-status\">Check a Service Status<\/h3>\n\n\n\n<p>View the current state and recent logs for a service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status nginx<\/code><\/pre>\n\n\n\n<p>The output shows whether it&#8217;s active or failed, its PID, memory usage, and the last 10 journal lines. It&#8217;s the first command to run when a service is behaving unexpectedly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-reading-systemctl-output-and-logs\">Reading systemctl Output and Logs<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-interpreting-service-states\">Interpreting Service States<\/h3>\n\n\n\n<p>The five states you&#8217;ll encounter in list-unit-files output:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>enabled: Service starts at boot via a symlink in \/etc\/systemd\/system\/ or similar.<\/li>\n\n\n\n<li>disabled: Service won&#8217;t start at boot but can be started manually.<\/li>\n\n\n\n<li>masked: Service is hard-disabled. It can&#8217;t be started even manually until unmasked.<\/li>\n\n\n\n<li>static: Service has no install section in its unit file. It only runs when another unit requires it.<\/li>\n\n\n\n<li>failed: systemd tried to start the service and it exited with an error.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-viewing-logs-with-journalctl\">Viewing Logs with journalctl<\/h3>\n\n\n\n<p>systemd captures all service output in the journal. View logs for a specific service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo journalctl -u nginx<\/code><\/pre>\n\n\n\n<p>Follow live output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo journalctl -u nginx -f<\/code><\/pre>\n\n\n\n<p>Show only the last 100 lines:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo journalctl -u nginx -n 100<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-linux-service-management-best-practices\">Linux Service Management Best Practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Audit running services periodically. Anything you didn&#8217;t install and don&#8217;t recognize should be investigated.<\/li>\n\n\n\n<li>Mask services you never want running, not just disable them. Disabling leaves the door open for packages to re-enable them.<\/li>\n\n\n\n<li>Use enable &#8211;now and disable &#8211;now to avoid split-brain states where a service is enabled but not running.<\/li>\n\n\n\n<li>Check failed services after every reboot: sudo systemctl &#8211;failed<\/li>\n\n\n\n<li>Don&#8217;t restart services in production without checking the reload option first. Reloading is less disruptive.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faq-linux-list-services\">FAQ: Linux List Services<\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1777033321179\"><strong class=\"schema-faq-question\">How do I list all running services in Linux?<\/strong> <p class=\"schema-faq-answer\">Run: sudo systemctl list-units &#8211;type=service &#8211;state=running. This shows only currently active services. For all installed services regardless of state, use: sudo systemctl list-unit-files &#8211;type=service<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1777033329338\"><strong class=\"schema-faq-question\">How do I start a service in Linux?<\/strong> <p class=\"schema-faq-answer\">Run: sudo systemctl start service-name. Replace service-name with the actual service (e.g., nginx, mysql, sshd). To also enable it at boot: sudo systemctl enable &#8211;now service-name<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1777033336713\"><strong class=\"schema-faq-question\">How do I enable a service at boot?<\/strong> <p class=\"schema-faq-answer\">Run: sudo systemctl enable service-name. This creates the necessary symlinks for the service to start automatically on boot. To start it immediately too, add &#8211;now: sudo systemctl enable &#8211;now service-name<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1777033345057\"><strong class=\"schema-faq-question\">What is the difference between stop and disable?<\/strong> <p class=\"schema-faq-answer\">stop halts the service right now but doesn&#8217;t change its boot behavior. disable removes the boot symlinks so it won&#8217;t start next reboot, but doesn&#8217;t affect the currently running instance. To both stop it now and prevent it from starting again, run: sudo systemctl disable &#8211;now service-name<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>A server with 40 running services and no idea which ones are actually needed is a security incident waiting to happen. systemctl gives you full visibility and control over every daemon on your system. How Linux Services Work Linux services are background processes that run independently of user sessions. They handle everything from web serving [&hellip;]<\/p>\n","protected":false},"author":44,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18],"tags":[],"ppma_author":[3402],"class_list":["post-30217","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Milan Ivanovic","author_link":"https:\/\/contabo.com\/blog\/author\/milan\/"},"uagb_comment_info":0,"uagb_excerpt":"A server with 40 running services and no idea which ones are actually needed is a security incident waiting to happen. systemctl gives you full visibility and control over every daemon on your system. How Linux Services Work Linux services are background processes that run independently of user sessions. They handle everything from web serving&hellip;","authors":[{"term_id":3402,"user_id":0,"is_guest":1,"slug":"contabro","display_name":"ContaBro","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/30217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/comments?post=30217"}],"version-history":[{"count":1,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/30217\/revisions"}],"predecessor-version":[{"id":30218,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/30217\/revisions\/30218"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=30217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=30217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=30217"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=30217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}