A service is a program that runs in the background.
We can add to remove services for a better experience. For example
we want our
NetworkManager service to automatically start on boot, so when we login,
we are connected to a network.
There are two scopes of services
- user scope: by adding the flag
--userto any of the commands, we will be running the service as a user. If it is
enabledit will start only once the user logs in.
- system scope: The service will start when the system boots up. (managed by the init system, systemd).
sudo systemctl start <service_name>: to start a service
sudo systemctl enable --now <service_name>: starts the service but also makes sure it is running when you turn your computer on / log in. If you don't need the service to run/start right now, you can omit the
sudo systemctl stop <service_name>: to stop a running service.
sudo systemctl disable <service_name>:Stop a service from running on startup.
sudo systemctl | grep running: see all the services that are running.
sudo systemctl list-unit-files | grep enabled: see the enabled services