Difference between revisions of "Linux Systemd"
m |
|||
Line 29: | Line 29: | ||
To stop the service, you use the stop flag with the systemctl command | To stop the service, you use the stop flag with the systemctl command | ||
sudo systemctl stop <service_name> | sudo systemctl stop <service_name> | ||
+ | |||
+ | Check the status of the service | ||
+ | sudo systemctl status <service_name> | ||
+ | |||
+ | ==Managing Services== | ||
+ | systemd can control components that run after boot and also maintain components indefinitely. These tasks are known as units, and each unit has a corresponding unit file. Units might concern mounting storage devices (.mount), configuring hardware (.device), sockets (.socket), or managing services (.service). | ||
Enabling service referes to start the service automatically at the system boot. | Enabling service referes to start the service automatically at the system boot. | ||
Line 36: | Line 42: | ||
sudo systemctl disable <service_name> | sudo systemctl disable <service_name> | ||
− | + | Each unit has a corresponding unit file. These unit files are usually located in the following directories: | |
− | + | *The /lib/systemd/system directory holds unit files that are provided by the system or are supplied by installed packages. This directory is also a symlink to /usr/lib/systemd/user/ directory. | |
+ | *The /etc/systemd/system directory stores unit files that are user-provided. |
Revision as of 14:20, 22 September 2024
systemd provides an array of system components for Linux operating systems. Its main aim is to unify service configuration and behavior across Linux distributions. It is the controlling interface and inspection tool for the init system and service manager systemd.
systemd replaces [Linux Sys V]] - We used to control system services with commands like "service httpd restart" and now we use instead the awkwardly syntaxed systemctl such as "systemctl restart httpd" or "systemctl restart apache2"
systemd uses the systemctl command
systemctl command
Command Description systemctl start [service] Start a service. systemctl stop [service] Stop a service. systemctl enable [service] Enable a service to start automatically at system boot. systemctl disable [service] Disable a service from starting automatically at system boot. systemctl status [service] View the status of a service. systemctl restart [service] Restart a service. systemctl reload [service] Reload a service's configuration without restarting it. systemctl mask [service] Prevent a service from being started. systemctl unmask [service] Allow a previously masked service to be started. systemctl set-default [target] Change the default system target (runlevel). systemctl list-unit-files List all installed unit files and their states. systemctl list-dependencies [unit] List the dependencies of a specific unit. systemctl list-sockets List all active sockets. systemctl list-jobs List all active systemd jobs. systemctl list-units Show the status of all loaded and active systemd units.
To start the service, all you have to do is use the start flag with the systemctl command
sudo systemctl start <service_name>
To stop the service, you use the stop flag with the systemctl command
sudo systemctl stop <service_name>
Check the status of the service
sudo systemctl status <service_name>
Managing Services
systemd can control components that run after boot and also maintain components indefinitely. These tasks are known as units, and each unit has a corresponding unit file. Units might concern mounting storage devices (.mount), configuring hardware (.device), sockets (.socket), or managing services (.service).
Enabling service referes to start the service automatically at the system boot.
sudo systemctl enable <service_name>
Prevent the service from auto starting at boot
sudo systemctl disable <service_name>
Each unit has a corresponding unit file. These unit files are usually located in the following directories:
- The /lib/systemd/system directory holds unit files that are provided by the system or are supplied by installed packages. This directory is also a symlink to /usr/lib/systemd/user/ directory.
- The /etc/systemd/system directory stores unit files that are user-provided.