Linux Services code example
Example 1: list all services using systemctl
## List all services
systemctl list-units --type=service
## List running services
systemctl list-units --type=service --state=running
## List all svc in simplified way
service --status-all
Example 2: ubuntu list running services
To check all running services
service --status-all | grep '\[ + \]'
To check all services (running & non running)
service --status-all
Example 3: linux view services
service --status-all
service --status-all | more
service --status-all | grep ntpd
service --status-all | less
Example 4: systemctl check availabe services
# systemctl list-units --type=service
OR
# systemctl --type=service
Example 5: how to make services in linux
[Unit]
Description=<description about this service>
[Service]
User=<user e.g. root>
WorkingDirectory=<directory_of_script e.g. /root>
ExecStart=<script which needs to be executed>
Restart=always
[Install]
WantedBy=multi-user.target