Chapter 9
CONTROLLING SERVICES AND DAEMONS
Linux konvensiyasına görə sonu d
hərfi ilə bitən fayllar daemon fayllarıdır.
systemd linuxda 1 saylı PİD ilə işə düşən ilk daemondur.
Service units
Aşağıdakı komanda vasitəsilə mövcud olan system unitlərə baxmaq mümkündür:
systemctl list-units -all # hər tip unitlərə bax
systemctl list-unit-files --all # hər tip unitlərə bax
systemctl list-unit-files --type=service. # servis tipli unitlərə bax
.service:
This unit type represents a process or a group of processes. It's used to manage system services.
.path:
Path units are used to trigger other units when file system objects change or when directories appear or disappear.
.scope:
Scope units manage a set of system processes. Unlike service units, scope units manage processes that have already been started.
.mount:
Mount units represent mount points in the filesystem hierarchy. They are used to manage filesystem mount points.
.automount:
Automount units provide an automounting mechanism, which allows on-demand mounting of file systems when they are accessed, and unmounting them when they are no longer needed.
.device:
Device units represent a device in the system, and they encapsulate device nodes present in the
/dev/
directory.
.socket:
Socket units represent network sockets or IPC sockets (inter-process communication). They are used to enable system services to communicate with each other or with other systems.
.swap:
Swap units represent swap spaces in the system. They are used to manage swap partitions or files.
.target:
Target units are used to group other units, creating a logical point of synchronization during the boot process. They do not represent a resource, but are used to model system states.
.timer:
Timer units are used to trigger activation of other units based on timers. They can work on real-time or monotonic time, and can be used to schedule the activation of other units.
Loaded
Whether the service unit is loaded into memory.
Active
Whether the service unit is running and if so, how long it has been running.
Main PID
The main process ID of the service, including the command name.
Status
Additional information about the service.
loaded
Unit configuration file has been processed.
active (running)
Running with one or more continuing processes.
active (exited)
Successfully completed a one-time configuration.
active (waiting)
Running but waiting for an event.
inactive
Not running.
enabled
Is started at boot time.
disabled
Is not set to be started at boot time.
static
Cannot be enabled, but may be started by an enabled unit automatically.
# Provides a detailed status of the sshd.service, including whether it is active and the most recent log entries.
systemctl status sshd.service
# Checks if the sshd.service is currently active (running).
systemctl is-active sshd.service
# Checks if the sshd.service is enabled to start at boot.
systemctl is-enabled sshd.service
# Checks if the sshd.service has entered a failed state.
systemctl is-failed sshd.service
# Lists all service units that have entered a failed state.
systemctl --failed --type=service
# Starts the sshd service immediately.
systemctl start sshd
# Starts the sshd.service immediately, same as above but with explicit unit type.
systemctl start sshd.service
# Stops the sshd.service immediately.
systemctl stop sshd.service
# Stops and then starts the sshd.service again.
systemctl restart sshd.service
# Reloads the configuration of sshd.service without disrupting current operations.
systemctl reload sshd.service
# Reloads the configuration if possible, otherwise stops and starts the sshd.service again.
systemctl reload-or-restart sshd.service
# Lists all units that sshd.service depends on.
systemctl list-dependencies sshd.service
MASKING AND UNMASKING SERVICES
# Prevents the sendmail.service from being started, manually or as a dependency.
systemctl mask sendmail.service
systemctl list-unit-files --type=service
systemctl start sendmail.service
# Reverses the masking of `sendmail.service`, allowing it to be started again, manually or as a dependency.
systemctl unmask sendmail.service
Last updated
Was this helpful?