Linux services with Systemd

In linux, a service (or daemon) is a script that runs in the background. It listens continuously for incoming requests and sends a response based on the given request. A service is different from a process as a process is an application or a script that can be running in the foreground or the background.

Any script can be turned up into a systemd service that will run automatically when system boots up. systemdgives us the systemctl commands suite which is mostly used to start, stop, reload, restart and check status of services.

Now, let’s define a simple bash script that will create a file named welcome

To turn this script into a service, we need to create welcome.service in /etc/systemd/system/welcome.service

ExecStart defines the path to welcome.shscript.

Before starting the service, make sure to make executable :

  • sudo chmod 0755 ~/

To start the service , run the following commands :

  • sudo systemctl daemon-reload
  • sudo systemctl start welcome

You can check the status of the service by running :

  • sudo systemctl status welcome



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store