How to Manage Systemd Services with Systemctl?

The default system and repair supervisor for many Linux distributions is now systemd.

The systemd course of replaces the SysV init. It runs as the primary course of after kernel boot and is chargeable for getting the Linux host right into a state the place it may be used. It’s chargeable for beginning and managing the companies, mounting file techniques, managing {hardware}, producing the login immediate and far more.

An vital benefit over SysV is that systemd begins as many companies as doable in parallel, dashing up the boot course of and making the login display seem sooner.


The objects managed by the system are known as items. The unit recordsdata are positioned in /lib/systemd/system.

Service Models

For service administration, the goal items are service items, which have unit recordsdata with the suffix of .make use of.

Handle system companies

The command to handle systemd items is systemctl.

Begin and cease companies

To start out a systemd service, use the systemctl begin command:

$ sudo systemctl begin identify.service

You possibly can depart the .service suffix. For instance, to start out the apache server on Ubuntu:

$ sudo systemctl begin apache2

To cease a operating service:

$ sudo systemctl cease identify.service

So to cease the apache server on Ubuntu:

$ sudo systemctl cease apache2

Restart and reload companies

To restart a operating service, use the restart command:

$ sudo systemctl restart identify.service

And the place the one reload configuration file is required

$ sudo systemctl reload identify.service

Allow and disable companies

In order for you a service to start out routinely at system startup, use the allow command:

$ sudo systemctl allow identify.service

To stop a service from beginning at system startup:

$ sudo systemctl disable identify.service

Disabling doesn’t cease a operating service.

View service standing

To view details about a service:

$ sudo systemctl standing identify.service

Right here you may see the standing of the service and the primary few traces of the log file. So whereas the service is operating, the output of

sudo systemctl standing apache2


apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
   Lively: energetic (operating) since Tue 2020-05-19 22:11:36 UTC; 4 days in the past
  Course of: 116002 ExecReload=/usr/sbin/apachectl sleek (code=exited, standing=0/SUCCESS)
Major PID: 104165 (apache2)
    Duties: 55 (restrict: 1024)
   CGroup: /system.slice/apache2.service
           ├─104165 /usr/sbin/apache2 -k begin
           ├─116006 /usr/sbin/apache2 -k begin
           └─116007 /usr/sbin/apache2 -k begin

Might 19 22:11:36 ubuntu18 systemd[1]: Beginning The Apache HTTP Server...
Might 19 22:11:36 ubuntu18 systemd[1]: Began The Apache HTTP Server.
Might 21 06:25:01 ubuntu18 systemd[1]: Reloading The Apache HTTP Server.
Might 21 06:25:01 ubuntu18 systemd[1]: Reloaded The Apache HTTP Server.
Might 22 06:25:01 ubuntu18 systemd[1]: Reloading The Apache HTTP Server.

To test if a service is operating:

$ sudo systemctl is-active identify.service

So whereas the apache2 service is operating, the output of the systemctl is-active command is:

$ sudo systemctl is-active apache2

To test if a service is enabled:

$ sudo systemctl is-enabled identify.service.

View system standing

All of the instructions you’ve got seen to date are used to handle a single service. To get an summary of the system standing, use the next sequence of instructions:

To see all unit varieties

$ sudo systemctl -t assist
Out there unit varieties:

To record all put in items, use list-unit-files

$ sudo systemctl list-unit-files
UNIT FILE                              STATE          
proc-sys-fs-binfmt_misc.automount      static         
-.mount                                generated      
boot-efi.mount                         generated      
dev-hugepages.mount                    static         
dev-mqueue.mount                       static         
mnt.mount                              generated      
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        
apport-autoreport.path                 enabled        
systemd-ask-password-console.path      static         
systemd-ask-password-plymouth.path     static         
systemd-ask-password-wall.path         static         
session-161.scope                      transient      
accounts-daemon.service                enabled        

The output has solely two columns Unit File and State. The state is often enabled, disabled, static, or masked.

  • Static: Which means the unit can’t be turned on, carry out a one-time motion, or relies on one other unit and can’t be managed by itself.
  • Masked: A unit listed as masked means it can’t be began in any respect, as it’s linked to /dev/null. That is known as unit masking. This prevents the service from beginning manually or routinely.

Listing all put in companies

The systemctl list-unit-files command with -t or –kind servicefilter solely exhibits the standing of put in companies.

$ sudo systemctl list-unit-files -t service
UNIT FILE                              STATE    
accounts-daemon.service                enabled  
acpid.service                          disabled 
apache-htcacheclean.service            disabled 
[email protected]           disabled 
apache2.service                        enabled  
[email protected]                       disabled 
apparmor.service                       enabled  
apport-autoreport.service              static   
[email protected]                static   
apport.service                         generated
apt-daily-upgrade.service              static   
apt-daily.service                      static   
atd.service                            enabled  
[email protected]                        enabled  
blk-availability.service               enabled  
bootlogd.service                       masked   
bootlogs.service                       masked   

To see all energetic service items, use record items with -t service filter

$ sudo systemctl list-units -t service
UNIT                                 LOAD   ACTIVE SUB     DESCRIPTION                             
  accounts-daemon.service              loaded energetic operating Accounts Service                        
  apache2.service                      loaded energetic operating The Apache HTTP Server                  
  apparmor.service                     loaded energetic exited  AppArmor initialization                 
  apport.service                       loaded energetic exited  LSB: automated crash report technology  
  atd.service                          loaded energetic operating Deferred execution scheduler            
  blk-availability.service             loaded energetic exited  Availability of block gadgets           
  cloud-config.service                 loaded energetic exited  Apply the settings laid out in cloud-con
  cloud-final.service                  loaded energetic exited  Execute cloud person/ultimate scripts        
  cloud-init-local.service             loaded energetic exited  Preliminary cloud-init job (pre-networking) 
  cloud-init.service                   loaded energetic exited  Preliminary cloud-init job (metadata service 
  console-setup.service                loaded energetic exited  Set console font and keymap             
  cron.service                         loaded energetic operating Common background program processing dae

The output has the next columns:

  • UNIT: The identify of the systemd service unit
  • LOAD: Signifies whether or not the unit definition was learn and loaded accurately
  • ACTIVE: Describes whether or not the unit is energetic.
  • SUB: Low-level activation standing of the unit, displaying extra detailed details about the unit. This may differ per unit kind.
  • DESCRIPTION: The outline of the service unit.


I hope this provides you an thought about utilizing systemctl to handle companies on Linux. If you wish to be taught extra, you may take a look at this Linux Mastery course.

Rate this post
porno izle altyazılı porno porno