Redhat Linux 9: Quản lý các systemd unit
Автор: Le Hoang Long Long
Загружено: 2023-12-02
Просмотров: 1
                Описание:
                    Link playlist
Red Hat Enterprise Linux Administration
   • Red Hat Enterprise Linux 9 Administration  
2023 12 02 21 30 48
Managing Units Through Systemd
Managing the current state of Systemd units is an important
task for RHEL administrators. Managing units means not only
managing their current state but also changing options used by
the different units.
Managing Systemd units starts with starting and stopping units.
As an administrator, you use the systemctl command to do
that. In Exercise 11-1, you start, stop, and manage a unit. After
you configure a unit so that it can be started without problems,
you need to make sure that it restarts automatically upon
reboot. You do this by enabling or disabling the unit.
Tip
The systemctl command has a large number of
options, which may appear overwhelming at first
sight, but there’s no need to be overwhelmed. Just
ensure that the bash-completion package is
installed and use Tab completion on the systemctl
command, which provides easy access to all of the
available options.
Exercise 11-1 Managing Units with systemctl
1. From a root shell, type dnf -y install vsftpd to install the
Very Secure FTP service.
2. Type systemctl start vsftpd to activate the FTP server on
your machine.
3. Type systemctl status vsftpd to get output like that shown
in Example 11-6, where you can see that the vsftpd service is
currently operational. In the Loaded line, you can also see
that the service is currently disabled, which means that it
will not be activated on a system restart. The vendor preset
also shows as disabled, which means that, by default, after
installation this unit will not automatically be enabled.
4. Type systemctl enable vsftpd to create a symbolic link in
the wants directory for the multiuser target to ensure that
the service is automatically started after a restart.
5. Type systemctl status vsftpd again. You’ll see that the unit
file has changed from being disabled to enabled.
Example 11-6 Requesting Current Unit Status with systemctl
status
Click here to view code image
[root@server1 system]# systemctl status vsftpd
• vsftpd.service - Vsftpd ftp daemon
 Loaded: loaded (/usr/lib/systemd/system/vsf
 vendor preset: disabled)
 Active: active (running) since Thu 2022-09-
 ago
 Process: 33967 ExecStart=/usr/sbin/vsftpd /e
 (code=exited, status=0/SUCCESS)
 Main PID: 33968 (vsftpd)
 Tasks: 1 (limit: 23272)
 Memory: 708.0K
 CPU: 2ms
 CGroup: /system.slice/vsftpd.service
 └─33968 /usr/sbin/vsftpd /etc/vsftp
p p
Sep 15 08:42:50 server1.example.com systemd[1]: 
 daemon...
Sep 15 08:42:50 server1.example.com systemd[1]: 
 daemon. .
When requesting the current status of a Systemd unit as in
Example 11-6, you can see different kinds of information about
it. Table 11-2 shows the different kinds of information that you
can get about unit files when using the systemctl status
command.
Table 11-2 Systemd Status Overview
Status Description
Loaded The unit file has been processed and the unit is active.
Active(running) The unit is running with one or more active processes.
Active(exited) The unit has successfully completed a one-time run.
Status Description
Active(waiting) The unit is running and waiting for an event.
Inactive(dead) The unit is not running.
Enabled The unit will be started at boot time.
Disabled The unit will not be started at boot time.
Static The unit cannot be enabled but may be started by another
unit automatically.
As an administrator, you also often need to get a current
overview of the current status of Systemd unit files. Different
commands, some of which are shown in Table 11-3, can help
you get this insight.
Table 11-3 systemctl Unit Overview Commands
Command Description
systemctl -t service Shows only service units
systemctl list-units -t
service
Shows all active service units (same result as the
previous command)
systemctl list-units -t
service --all
Shows inactive service units as well as active
service units
systemctl --failed -t
service
Shows all services that have failed
systemctl status -l
your.service
Shows detailed status information about services                
                
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
- 
                                
Информация по загрузке: