RHEL-8-Configuring Basic System Settings
RHEL-8-Configuring Basic System Settings
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons
Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is
available at
http://creativecommons.org/licenses/by-sa/3.0/
. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must
provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert,
Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift,
Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States
and other countries.
Linux ® is the registered trademark of Linus Torvalds in the United States and other countries.
XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States
and/or other countries.
MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and
other countries.
Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the
official Joyent Node.js open source or commercial project.
The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks
or trademarks/service marks of the OpenStack Foundation, in the United States and other
countries and are used with the OpenStack Foundation's permission. We are not affiliated with,
endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
Abstract
This document describes basics of system administration on Red Hat Enterprise Linux 8. The title
focuses on: basic tasks that a system administrator needs to do just after the operating system has
been successfully installed, installing software with yum, using systemd for service management,
managing users, groups and file permissions, using chrony to configure NTP, working with Python 3
and others.
Table of Contents
Table of Contents
.CHAPTER
. . . . . . . . . . 1.. .GETTING
. . . . . . . . . . STARTED
. . . . . . . . . . .WITH
. . . . . .SYSTEM
. . . . . . . . .ADMINISTRATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9. . . . . . . . . . . . .
1.1. CONFIGURING SYSTEM SETTINGS IN THE WEB CONSOLE 9
1.1.1. What the RHEL 8 web console is and which tasks it can be used for 9
1.1.2. Using the web console to restart the system 10
1.1.3. Using the web console to shutdown the system 11
1.1.4. Using the web console for setting a host name 12
1.1.5. Joining the RHEL 8 system to the IdM domain using the web console 14
1.1.6. Using the web console for configuring time settings 17
1.1.7. Using the web console for selecting performance profiles 18
1.1.8. Disabling SMT to prevent CPU security issues 19
1.2. WHAT RHEL SYSTEM ROLES ARE AND WHICH TASKS THEY CAN BE USED FOR 21
1.2.1. Introduction to RHEL System Roles 21
1.2.2. Applying a role 21
1.3. CHANGING BASIC ENVIRONMENT SETTINGS 23
1.3.1. Configuring the date and time 23
1.3.1.1. Displaying the current date and time 23
1.3.1.2. Additional resources 24
1.3.2. Configuring the system locale 24
1.3.3. Configuring the keyboard layout 25
1.3.4. Changing the language using desktop GUI 25
1.3.5. Additional resources 28
1.4. CONFIGURING AND MANAGING NETWORK ACCESS 28
1.4.1. Configuring the network and host name in the graphical installation mode 28
1.4.2. Adding a static Ethernet connection using nmcli 29
1.4.3. Adding a connection profile using nmtui 31
1.4.4. Managing networking in the RHEL 8 web console 33
1.4.5. Managing networking using RHEL System Roles 33
1.4.6. Additional resources 35
1.5. REGISTERING THE SYSTEM AND MANAGING SUBSCRIPTIONS 35
1.5.1. Registering the system after the installation 35
1.5.2. Registering subscriptions with credentials in the web console 35
1.5.3. Registering a system using Red Hat account on GNOME 38
1.5.4. Registering a system using Activation Key on GNOME 39
1.6. INSTALLING SOFTWARE 39
1.6.1. Prerequisites for software installation 39
1.6.2. Introduction to the system of software packaging and software repositories 40
1.6.3. Managing basic software-installation tasks with subscription manager and yum 40
1.7. MAKING SYSTEMD SERVICES START AT BOOT TIME 41
1.7.1. Enabling or disabling the services 41
1.7.2. Managing services in the RHEL 8 web console 42
1.8. ENHANCING SYSTEM SECURITY WITH A FIREWALL, SELINUX, AND SSH ACCESS 42
1.8.1. Ensuring the firewall is enabled and running 42
1.8.1.1. What a firewall is and how it enhances system security 42
1.8.1.2. Re-enabling the firewalld service 42
1.8.1.3. Managing firewall in the RHEL 8 web console 43
1.8.2. SELinux and its modes 43
SELinux states 43
SELinux modes 43
1.8.3. Ensuring the required state of SELinux 44
1.8.3.1. Switching SELinux modes in the RHEL 8 web console 45
1.8.4. Managing SELinux on multiple systems using RHEL System Roles and Ansible 45
1
Red Hat Enterprise Linux 8 Configuring basic system settings
. . . . . . . . . . . 2.
CHAPTER . . MANAGING
. . . . . . . . . . . . .SOFTWARE
. . . . . . . . . . . . .PACKAGES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
..............
2.1. SOFTWARE MANAGEMENT TOOLS IN RED HAT ENTERPRISE LINUX 8 55
2.2. APPLICATION STREAMS 55
2.3. SEARCHING FOR SOFTWARE PACKAGES 55
2.3.1. Searching packages with yum 56
2.3.2. Listing packages with yum 56
2.3.3. Listing repositories with yum 56
2.3.4. Displaying package information with yum 57
2.3.5. Listing package groups with yum 57
2.3.6. Specifying global expressions in yum input 57
2.4. INSTALLING SOFTWARE PACKAGES 58
2.4.1. Installing packages with yum 58
2.4.2. Installing a package group with yum 59
2.4.3. Specifying a package name in yum input 59
2.5. UPDATING SOFTWARE PACKAGES 60
2.5.1. Checking for updates with yum 60
2.5.2. Updating a single package with yum 60
2.5.3. Updating a package group with yum 60
2.5.4. Updating all packages and their dependencies with yum 60
2.5.5. Updating security-related packages with yum 61
2.5.6. Automating software updates 61
2.5.6.1. How DNF Automatic operates 61
2.5.6.2. DNF Automatic configuration file 62
2.5.6.3. Enabling DNF Automatic 62
2.6. UNINSTALLING SOFTWARE PACKAGES 63
2.6.1. Removing packages with yum 63
2.6.2. Removing a package group with yum 64
2.6.3. Specifying a package name in yum input 64
2
Table of Contents
. . . . . . . . . . . 3.
CHAPTER . . MANAGING
. . . . . . . . . . . . . SERVICES
. . . . . . . . . . .WITH
. . . . . . SYSTEMD
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
..............
3.1. INTRODUCTION TO SYSTEMD 72
Overriding the default systemd configuration using system.conf 73
3.1.1. Main features 73
3.1.2. Compatibility changes 74
3.2. MANAGING SYSTEM SERVICES 75
Specifying service units 76
Behavior of systemctl in a chroot environment 77
3.2.1. Listing services 77
3.2.2. Displaying service status 78
3.2.3. Starting a service 80
3.2.4. Stopping a service 80
3.2.5. Restarting a service 81
3.2.6. Enabling a service 81
3.2.7. Disabling a service 82
3.2.8. Starting a conflicting service 83
3.3. WORKING WITH SYSTEMD TARGETS 83
3.3.1. Viewing the default target 84
3.3.2. Viewing the current target 84
3.3.3. Changing the default target 85
3.3.4. Changing the current target 86
3.3.5. Changing to rescue mode 86
3.3.6. Changing to emergency mode 87
3.4. SHUTTING DOWN, SUSPENDING, AND HIBERNATING THE SYSTEM 87
3.4.1. Shutting down the system 88
Using systemctl commands 88
Using the shutdown command 88
3.4.2. Restarting the system 89
3.4.3. Suspending the system 89
3.4.4. Hibernating the system 89
3
Red Hat Enterprise Linux 8 Configuring basic system settings
. . . . . . . . . . . 4.
CHAPTER . . .MANAGING
. . . . . . . . . . . . USER
. . . . . . AND
. . . . . .GROUP
. . . . . . . .ACCOUNTS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
..............
4.1. INTRODUCTION TO USERS AND GROUPS 113
4.2. RESERVED USER AND GROUP IDS 113
4.3. USER PRIVATE GROUPS 113
4.4. MANAGING USERS IN A GRAPHICAL ENVIRONMENT 114
4.4.1. Opening the Users settings tool 114
4.4.2. Modifying user accounts in Users settings tool 115
4.4.2.1. Adding a user with the Users settings tool 115
4.4.2.2. Removing a user with Users settings tool 115
4.4.2.3. Adding a user to the wheel group with the Users settings tool 115
4.4.2.4. Editing a user’s language with the Users settings tools 115
4.4.2.5. Managing passwords with the Users settings tool 116
4.5. MANAGING USERS USING COMMAND-LINE TOOLS 116
4.5.1. Command-line utilities for managing users and groups 116
4.5.2. Adding a new user 117
4.5.2.1. Applying the useradd command to add a new user 117
4.5.2.2. Unlocking a user account 118
4.5.2.3. Common command-line options for the useradd command 118
4.5.2.4. Range of IDs for system and normal users 118
4.5.2.5. Additional resources 119
4.5.3. Adding a new group 119
4.5.3.1. Applying the groupadd command to add a new group 119
4.5.3.2. Additional resources 119
4.5.4. Adding an existing user to an existing group 119
4.5.4.1. Overriding user’s primary group 119
4.5.4.2. Overriding user’s supplementary groups 120
4.5.4.3. Adding a group to user’s supplementary groups 120
4.5.5. Creating group directories 120
4.5.5.1. Creating a group directory - an example use case 120
4.6. MANAGING SUDO ACCESS 121
4
Table of Contents
. . . . . . . . . . . 5.
CHAPTER . . MANAGING
. . . . . . . . . . . . .FILE
. . . . . PERMISSIONS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
...............
5.1. SETTING DEFAULT PERMISSIONS FOR NEW FILES USING UMASK 133
5.1.1. What umask consists of 133
5.1.2. How umask works 133
5.1.3. Managing umask in Shells 134
5.1.3.1. Displaying the current mask in octal notation 134
5.1.3.2. Displaying the current mask in symbolic notation 135
5.1.3.3. Setting mask in shell using umask with octal notation 135
5.1.3.4. Setting mask in shell using umask with symbolic notation 135
5.1.3.5. Working with the default shell umask 136
5.1.3.5.1. Displaying the default bash umask 136
5.1.3.5.2. Changing the default bash umask 136
5.1.3.5.3. Changing the default bash umask for a specific user 136
5.1.3.6. Setting default permissions for newly created home directories 137
. . . . . . . . . . . 6.
CHAPTER . . .USING
. . . . . . .THE
. . . . .CHRONY
. . . . . . . . . .SUITE
. . . . . . TO
. . . .CONFIGURE
. . . . . . . . . . . . . NTP
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
...............
6.1. INTRODUCTION TO CONFIGURING NTP WITH CHRONY 138
6.2. INTRODUCTION TO CHRONY SUITE 138
6.2.1. Using chronyc to control chronyd 138
6.3. DIFFERENCES BETWEEN CHRONY AND NTP 139
6.4. MIGRATING TO CHRONY 139
6.4.1. Migration script 140
6.4.2. Timesync role 141
6.5. CONFIGURING CHRONY 141
6.5.1. Configuring chrony for security 145
6.6. USING CHRONY 146
6.6.1. Installing chrony 146
6.6.2. Checking the status of chronyd 146
6.6.3. Starting chronyd 146
6.6.4. Stopping chronyd 147
6.6.5. Checking if chrony is synchronized 147
6.6.5.1. Checking chrony tracking 147
6.6.5.2. Checking chrony sources 148
6.6.5.3. Checking chrony source statistics 150
6.6.6. Manually Adjusting the System Clock 150
5
Red Hat Enterprise Linux 8 Configuring basic system settings
. . . . . . . . . . . 7.
CHAPTER . . USING
. . . . . . . .SECURE
. . . . . . . . .COMMUNICATIONS
. . . . . . . . . . . . . . . . . . . . .BETWEEN
. . . . . . . . . . .TWO
. . . . . SYSTEMS
. . . . . . . . . . . WITH
. . . . . . OPENSSH
. . . . . . . . . . . . . . . . . . . . . . .159
...............
7.1. SSH AND OPENSSH 159
7.2. CONFIGURING AND STARTING AN OPENSSH SERVER 160
7.3. USING KEY PAIRS INSTEAD OF PASSWORDS FOR SSH AUTHENTICATION 161
7.3.1. Setting an OpenSSH server for key-based authentication 161
7.3.2. Generating SSH key pairs 162
7.4. USING SSH KEYS STORED ON A SMART CARD 163
7.5. MAKING OPENSSH MORE SECURE 165
7.6. CONNECTING TO A REMOTE SERVER USING AN SSH JUMP HOST 167
7.7. ADDITIONAL RESOURCES 168
.CHAPTER
. . . . . . . . . . 8.
. . .CONFIGURING
...............A
. . REMOTE
. . . . . . . . . .LOGGING
. . . . . . . . . . .SOLUTION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170
...............
8.1. THE RSYSLOG LOGGING SERVICE 170
8.2. INSTALLING RSYSLOG DOCUMENTATION 170
8.3. CONFIGURING A SERVER FOR REMOTE LOGGING OVER TCP 171
8.4. CONFIGURING REMOTE LOGGING TO A SERVER OVER TCP 172
8.5. ADDITIONAL RESOURCES 174
.CHAPTER
. . . . . . . . . . 9.
. . .USING
. . . . . . .PYTHON
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
...............
9.1. INTRODUCTION TO PYTHON 175
9.1.1. Python versions 175
9.1.2. The internal platform-python package 176
9.2. INSTALLING AND USING PYTHON 176
9.2.1. Installing Python 3 176
9.2.2. Installing Python 2 176
9.2.3. Using Python 3 177
9.2.4. Using Python 2 177
9.2.5. Configuring the unversioned Python 177
9.2.5.1. Configuring the unversioned python command to Python 3 directly 178
9.2.5.2. Configuring the unversioned python command to Python 2 directly 178
9.2.5.3. Configuring the unversioned python command to the required Python version interactively 178
9.3. MIGRATION FROM PYTHON 2 TO PYTHON 3 179
9.4. PACKAGING OF PYTHON 3 RPMS 179
6
Table of Contents
. . . . . . . . . . . 10.
CHAPTER . . . USING
. . . . . . . .LANGPACKS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184
...............
10.1. CHECKING LANGUAGES THAT PROVIDE LANGPACKS 184
10.2. WORKING WITH RPM WEAK DEPENDENCY-BASED LANGPACKS 184
10.2.1. Listing already installed language support 184
10.2.2. Checking the availability of language support 184
10.2.3. Listing packages installed for a language 185
10.2.4. Installing language support 185
10.2.5. Removing language support 185
10.3. SAVING DISK SPACE BY USING GLIBC-LANGPACK-<LOCALE_CODE> 185
.CHAPTER
. . . . . . . . . . 11.
. . .GETTING
. . . . . . . . . .STARTED
. . . . . . . . . . WITH
. . . . . . TCL/TK
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187
...............
11.1. INTRODUCTION TO TCL/TK 187
11.2. NOTABLE CHANGES IN TCL/TK 8.6 187
11.3. MIGRATING TO TCL/TK 8.6 188
11.3.1. Migration path for developers of Tcl extensions 188
11.3.2. Migration path for users scripting their tasks with Tcl/Tk 188
.CHAPTER
. . . . . . . . . . 12.
. . . USING
. . . . . . . PREFIXDEVNAME
. . . . . . . . . . . . . . . . . . . FOR
. . . . . NAMING
. . . . . . . . . .OF
. . . ETHERNET
. . . . . . . . . . . . NETWORK
. . . . . . . . . . . .INTERFACES
. . . . . . . . . . . . . . . . . . . . . . . . .190
...............
12.1. INTRODUCTION TO PREFIXDEVNAME 190
12.2. SETTING PREFIXDEVNAME 190
12.3. LIMITATIONS OF PREFIXDEVNAME 190
7
Red Hat Enterprise Linux 8 Configuring basic system settings
8
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
NOTE
The following basic administration tasks may include items that are usually done already
during the installation process, but they do not have to be done necessarily, such as the
registration of the system. The sections dealing with such tasks provide a summary of
how you can achieve the same goals during the installation.
For information on Red Hat Enterprise Linux installation, see Performing a standard
RHEL installation.
Although you can perform all post-installation tasks through the command line, you can also use the
RHEL 8 web console to perform some of them.
1.1.1. What the RHEL 8 web console is and which tasks it can be used for
The RHEL 8 web console is an interactive server administration interface. It interacts directly with the
operating system from a real Linux session in a browser.
9
Red Hat Enterprise Linux 8 Configuring basic system settings
Managing packages
Configuring SELinux
Updating software
For more information on installing and using the RHEL 8 web console, see Managing systems using the
RHEL 8 web console.
Prerequisites
Procedure
2. Click Overview.
4. If there are users logged into the system, write a reason for the restart in the Restart dialog box.
10
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
6. Click Restart.
Prerequisites
Procedure
2. Click Overview.
4. If there are users logged in to the system, write a reason for the shutdown in the Shut Down
dialog box.
11
Red Hat Enterprise Linux 8 Configuring basic system settings
Domain — If you want to use the machine in the network and use names instead of just IP
addresses, you need to add the domain as a suffix behind the host name. For example:
mymachine.example.com
You can configure also a pretty host name in the RHEL web console. The pretty host name allows you to
enter a host name with capital letters, spaces, and so on. The pretty host name displays in the web
console, but it does not have to correspond with the host name.
Example:
Host names are stored in the /etc/hostname file, however, you can set or change the host name in the
web console.
Prerequisites
Procedure
2. Click Overview.
12
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
4. In the Change Host Name dialog box, enter the host name in the Pretty Host Name field.
5. In the Real Host Name field, the pretty name will be compounded with a domain name.
You can change the host name manually if it does not correspond with the pretty host name.
6. Click Change.
Verification steps
2. Reopen the web console using an address with the new host name to the address bar of your
browser.
13
Red Hat Enterprise Linux 8 Configuring basic system settings
1.1.5. Joining the RHEL 8 system to the IdM domain using the web console
The following procedure describes joining the RHEL 8 system to the IdM domain.
Prerequisites
IdM domain running and reachable from the client you want to join.
Procedure
14
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
4. In the Join a Domain dialog box, enter the host name of the IdM server in the Domain Address
field.
5. In the Authentication drop down list, select if you want to use password or one time password
for authentication.
6. In the Domain Administrator Name field, enter the user name of the IdM administration
account.
7. In the password field, add the password or one time password according to what you selected in
the Authentication drop down list above.
8. Click Join.
15
Red Hat Enterprise Linux 8 Configuring basic system settings
If the RHEL 8 web console did not display an error, the system has been joined to the IdM domain and
you can see the domain name in the System screen.
WARNING
If you click to the joined domain in the System screen, the system will display a
warning dialog with the information about leaving the domain. If you click Leave, the
system will leave the domain.
16
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
Prerequisites
Procedure
3. In the Change System Time dialog box, change the time zone if necessary.
17
Red Hat Enterprise Linux 8 Configuring basic system settings
4. In the Set Time drop down menu, select one option from:
a. Manually
b. Automatically using NTP server — This is a default option. If the time of the system is
correct, leave it as it is.
c. Automatically using specific NTP servers — Use this option only if you need to synchronize
the system with a specific NTP server and add the DNS name or IP address of the server.
5. Click Change.
Latency performance
Network performance
Virtual machines
The following procedure describes setting up performance profiles in the web console.
For details about the tuned service, see Monitoring and managing system status and performance .
Prerequisites
Procedure
18
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
2. Click Overview.
4. In the Change Performance Profile dialog box, change the profile if necessary.
IMPORTANT
19
Red Hat Enterprise Linux 8 Configuring basic system settings
Prerequisites
Procedure
2. Click System.
5. In the CPU Security Toggles, switch on the Disable simultaneous multithreading (nosmt)
option.
20
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
Additional resources
For more details on security attacks that you can prevent by disabling SMT, see:
1.2. WHAT RHEL SYSTEM ROLES ARE AND WHICH TASKS THEY CAN
BE USED FOR
Red Hat Enterprise Linux System Roles were introduced with Red Hat Enterprise Linux 7.4. For more
information, see the Red Hat Enterprise Linux (RHEL) System Roles Red Hat KnowledgeBase article.
On Red Hat Enterprise Linux 8, the interface currently consists of the following roles:
selinux
kdump
network
timesync
storage
All these roles are provided by the rhel-system-roles package available in the AppStream repository.
Prerequisites
The rhel-system-roles package has been installed on the system that you want to use as a
control node:
The Ansible Engine repository has been enabled, and the ansible package has been installed on
the system that you want to use as a control node. The ansible package is needed to run
playbooks that use Red Hat Enterprise Linux System Roles.
If you do not have a Red Hat Ansible Engine Subscription, you can use a limited supported
version of Red Hat Ansible Engine provided with your Red Hat Enterprise Linux
subscription. In this case, follow these steps:
21
Red Hat Enterprise Linux 8 Configuring basic system settings
# subscription-manager refresh
# subscription-manager repos --enable ansible-2-for-rhel-8-x86_64-rpms
If you have a Red Hat Ansible Engine Subscription, follow the procedure described in
How do I Download and Install Red Hat Ansible Engine?.
A playbook is a list of one or more plays. Every play can include Ansible variables, tasks or roles.
Playbooks are human-readable, and they are expressed in the YAML format.
Procedure
---
- hosts: webservers
roles:
- rhel-system-roles.network
- rhel-system-roles.timesync
NOTE
Every role includes a README file, which documents how to use the role and
supported parameter values. You can also find an example playbook for a
particular role under the documentation directory of the role. Such
documentation directory is provided by default with the rhel-system-roles
package, and can be found in the following location:
/usr/share/doc/rhel-system-roles-<version>/SUBSYSTEM/
where SUBSYSTEM is the name of the subsystem that contains the individual
role manages - selinux, kdump, network or timesync.
22
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
An inventory is a list of systems against which Ansible works. For more information on how to
create and inventory, and how to work with it, see Ansible documentation.
If you have not created an inventory in advance, you can do so even at the time of running
ansible-playbook:
For cases with only one targeted host against which you want to run the playbook, use:
For cases with multiple targeted hosts against which you want to run the playbook, use:
For more detailed information on using the ansible-playbook command, see the ansible-
playbook man page.
System locales
Keyboard layout
Language
Red Hat Enterprise Linux 8 uses the chronyd daemon to implement NTP. chronyd is available from the
chrony package. For more information, see Using the chrony suite to configure NTP .
To display the current date and time, use either of these steps.
Procedure
$ date
Mon Mar 30 16:02:59 CEST 2020
23
Red Hat Enterprise Linux 8 Configuring basic system settings
$ timedatectl
Local time: Mon 2020-03-30 16:04:42 CEST
Universal time: Mon 2020-03-30 14:04:42 UTC
RTC time: Mon 2020-03-30 14:04:41
Time zone: Europe/Prague (CEST, +0200)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Additional resources
For more information, see the date(1) and timedatectl(1) man pages.
For more information on time settings in the web console, see Using the web console for
configuring time settings.
Procedure
$ localectl list-locales
C.utf8
aa_DJ
aa_DJ.iso88591
aa_DJ.utf8
...
$ localectl status
3. To set or change the default system locale settings, use a localectl set-locale sub-command as
the root user. For example:
Additional resources
For more information, see the localectl(1), locale(7), and locale.conf(5) man pages.
24
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
Procedure
$ localectl list-keymaps
ANSI-dvorak
al
al-plisi
amiga-de
amiga-us
...
$ localectl status
...
VC Keymap: us
...
3. To set or change the default system keymap, use a localectl set-keymap sub-command as the
root user. For example:
# localectl set-keymap us
Additional resources
For more information, see the localectl(1), locale(7), and locale.conf(5) man pages.
Prerequisites
Procedure
1. Open the GNOME Control Center from the System menu by clicking on its icon.
25
Red Hat Enterprise Linux 8 Configuring basic system settings
2. In the GNOME Control Center, choose Region & Language from the left vertical bar.
26
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
If your region and language are not listed, scroll down, and click More to select from available
regions and languages.
5. Click Done.
NOTE
27
Red Hat Enterprise Linux 8 Configuring basic system settings
NOTE
Some applications do not support certain languages. The text of an application that
cannot be translated into the selected language remains in US English.
Additional resources
For more information on how to launch the GNOME Control Center, see approaches described
in Launching applications
1.4.1. Configuring the network and host name in the graphical installation mode
Follow the steps in this procedure to configure your network and host name.
Procedure
1. From the Installation Summary window, click Network and Host Name*.
2. From the list in the left-hand pane, select an interface. The details are displayed in the right-
hand pane.
NOTE
4. Click + to add a virtual network interface, which can be either: Team, Bond, Bridge, or VLAN.
6. Click Configure to change settings such as IP addresses, DNS servers, or routing configuration
for an existing interface (both virtual and physical).
7. Type a host name for your system in the Host Name field.
NOTE
28
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
NOTE
There are several types of network device naming standards used to identify
network devices with persistent names, for example, em1 and wl3sp0. For
information about these standards, see the Configuring and managing
networking document.
The host name can be either a fully-qualified domain name (FQDN) in the
format hostname.domainname, or a short host name with no domain name.
Many networks have a Dynamic Host Configuration Protocol (DHCP) service
that automatically supplies connected systems with a domain name. To allow
the DHCP service to assign the domain name to this machine, specify only
the short host name. The value localhost.localdomain means that no
specific static host name for the target system is configured, and the actual
host name of the installed system is configured during the processing of the
network configuration, for example, by NetworkManager using DHCP or
DNS.
For details about configuring network settings and the host name when using a Kickstart file, see
the corresponding appendix in Performing an advanced RHEL installation .
If you install Red Hat Enterprise Linux using the text mode of the Anaconda installation
program, use the Network settings option to configure the network.
Procedure
The further steps modify the Example-Connection connection profile you created.
29
Red Hat Enterprise Linux 8 Configuring basic system settings
To set multiple DNS servers, specify them space-separated and enclosed in quotes.
6. Set the DNS search domain for the IPv4 and IPv6 connection:
Verification steps
Additional resources
30
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
See the nm-settings(5) man page for more information on connection profile properties and
their settings.
For further details about the nmcli utility, see the nmcli(1) man page.
Prerequisites
Procedure
# nmtui
31
Red Hat Enterprise Linux 8 Configuring basic system settings
9. Select the new connection entry, and press Enter to activate the connection.
Verification steps
32
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
Additional resources
For further details about the nmtui application, see the nmtui(1) man page.
33
Red Hat Enterprise Linux 8 Configuring basic system settings
You can configure the networking connections on multiple target machines using the network role.
Ethernet
Bridge
Bonded
VLAN
MacVLAN
Infiniband
The required networking connections for each host are provided as a list within the
network_connections variable.
WARNING
The network role updates or creates all connection profiles on the target system
exactly as specified in the network_connections variable. Therefore, the network
role removes options from the specified profiles if the options are only present on
the system but not in the network_connections variable.
The following example shows how to apply the network role to ensure that an Ethernet connection with
the required parameters exists:
Example 1.1. An example playbook applying the network role to set up an Ethernet connection
with the required parameters
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: network-test
vars:
network_connections:
roles:
- rhel-system-roles.network
34
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
For more information on applying a system role, see What RHEL System Roles are and which tasks they
can be used for.
Registered systems
If you have not registered your system during the installation process, you can do it afterwards by
applying the following procedure. Note that all commands in this procedure need to be performed as the
root user.
# subscription-manager register
The command will prompt you to enter your Red Hat Customer Portal user name and password.
This command displays all available subscriptions for your Red Hat account. For every
subscription, various characteristics are displayed, including the pool ID.
3. Attach the appropriate subscription to your system by replacing pool_id with the pool ID
determined in the previous step:
The following describes subscribing the newly installed Red Hat Enterprise Linux using the RHEL 8 web
35
Red Hat Enterprise Linux 8 Configuring basic system settings
The following describes subscribing the newly installed Red Hat Enterprise Linux using the RHEL 8 web
console.
Prerequisites
Procedure
1. Type subscription in the search field and press the Enter key.
Alternatively, you can log in to the RHEL 8 web console. For details, see Logging in to the web
console.
2. In the polkit authentication dialog for privileged tasks, add the password belonging user name
displayed in the dialog.
3. Click Authenticate.
36
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
37
Red Hat Enterprise Linux 8 Configuring basic system settings
Prerequisites
Procedure
1. Go to the system menu, which is accessible from the top-right screen corner and click the
Settings icon.
4. If you are not using the Red Hat server, enter the server address in the URL field.
38
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
Enter your Red hat account user name in the Login field,
7. Click Register.
Prerequisites
Procedure
1. Go to the system menu, which is accessible from the top-right screen corner and click the
Settings icon.
4. Enter URL to the customized server, if you are not using the Red Hat server.
7. Click Register.
39
Red Hat Enterprise Linux 8 Configuring basic system settings
You can start installing software once you have registered your system and attached a subscription, as
described in Section 1.5.1, “Registering the system after the installation” .
Installing packages
Updating packages
Removing packages
For information on basic tasks related to the installation of software, see Managing basic software-
installation tasks with subscription manager and yum.
$ yum repolist
Installing a package:
40
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
# yum update
Updating a package:
This section provides information on how to ensure that a service is enabled or disabled at boot time. It
also explains how to manage the services through the web console.
To create the list of services enabled or disabled at boot time during the installation process, use the
services option in your Kickstart file:
NOTE
The list of disabled services is processed before the list of enabled services. Therefore, if
a service appears on both lists, it is enabled. The list of the services uses the comma-
separated format. Do not include spaces in the list of services.
41
Red Hat Enterprise Linux 8 Configuring basic system settings
For further details on enabling and disabling services, see Section 3.2, “Managing system services” .
Computer security includes a wide variety of features and tools. This section covers only the basic
security features that you need to configure after you have installed the operating system. For detailed
information on securing Red Hat Enterprise Linux, see the titles from the Security section in Product
Documentation for Red Hat Enterprise Linux 8.
A firewall is a network security system that monitors and controls the incoming and outgoing network
traffic based on predetermined security rules. A firewall typically establishes a barrier between a trusted,
secure internal network and another outside network.
The firewall is provided by the firewalld service, which is automatically enabled during the installation.
However, if you explicitly disabled the service, you can re-enable it, as described in Section 1.8.1.2, “Re-
enabling the firewalld service”.
In case that the firewalld service is disabled after the installation, Red Hat recommends to consider re-
enabling it.
42
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
If firewalld is not enabled and running, switch to the root user, and change its status:
For detailed information on configuring and using firewall, see Using and configuring firewalls .
In the web console, use the Firewall option under Networking to enable or disable the firewalld
service.
By default, the firewalld service in the web console is enabled. To disable it, set off as shown below.
Additionally, you can choose the services that you want to allow through firewall.
SELinux states
SELinux has two possible states:
Enabled
Disabled
When SELinux is disabled, only Discretionary Access Control (DAC) rules are used.
SELinux modes
When SELinux is enabled, it can run in one of the following modes:
Enforcing
Permissive
Enforcing mode means that SELinux policies are enforced. SELinux denies access based on SELinux
policy rules, and enables only the interactions that are particularly allowed. Enforcing mode is the default
mode after the installation and it is also the safest SELinux mode.
43
Red Hat Enterprise Linux 8 Configuring basic system settings
Permissive mode means that SELinux policies are not enforced. SELinux does not deny access, but
denials are logged for actions that would have been denied if running in enforcing mode. Permissive
mode is the default mode during the installation. Operating in permissive mode is also useful in some
specific cases, for example if you require access to the Access Vector Cache (AVC) denials when
troubleshooting problems.
However, in specific scenarios, you can set SELinux to permissive mode or even disable it on the
installed operating system.
IMPORTANT
Red Hat recommends to keep your system in enforcing mode. For debugging purposes,
set SELinux to permissive mode.
To display the current SELinux mode, and to set the mode as required:
$ getenforce
# setenforce Enforcing
# setenforce Permissive
To permanently set SELinux mode, modify the SELINUX variable in the /etc/selinux/config
configuration file.
For example, to switch SELinux to enforcing mode:
44
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
WARNING
For more information on permanent changes of SELinux modes, see Changing SELinux
states and modes in the Using SELinux title.
In the web console, use the SELinux option to turn SELinux enforcing policy on or off.
By default, SELinux enforcing policy in the web console is on, and SELinux operates in enforcing mode.
By turning it off, you can switch SELinux to permissive mode. Note that such deviation from the default
configuration in the /etc/sysconfig/selinux file is automatically reverted on the next boot.
1.8.4. Managing SELinux on multiple systems using RHEL System Roles and Ansible
You can manage various SELinux local customizations on multiple target machines using the selinux
system role.
For more information on applying the selinux role to manage various local customizations, such as
applying the restorecon command to portions of file system tree, or managing file contexts, SELinux
booleans, logins, or ports, see the Deploying the same SELinux configuration on multiple systems
45
Red Hat Enterprise Linux 8 Configuring basic system settings
section.
For more information, see the Using secure communications between two systems with OpenSSH
section.
System accounts represent a particular applications identifier on a system. Such accounts are generally
added or manipulated only at software installation time, and they are not modified later.
WARNING
For system accounts, user IDs below 1000 are reserved. For normal accounts, you can use IDs starting
at 1000. However, the recommended practice is to assign IDs starting at 5000. See Reserved user and
group IDs for more information. The guidelines for assigning IDs can be found in the /etc/login.defs file:
What groups are and which purposes they can be used for
A group in an entity which ties together multiple user accounts for a common purpose, such as granting
access to particular files.
46
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
The most basic tasks to manage user accounts and groups, and the appropriate command-line tools,
include:
$ id
# passwd user_name
For detailed information on managing users and groups, see Section 4.1, “Introduction to Users and
Groups”.
The RHEL 8 web console displays all user accounts located in the system. Therefore, you can see at
least one user account just after the first login to the web console.
Ones you are logged in to the RHEL 8 web console, you can:
Lock accounts.
47
Red Hat Enterprise Linux 8 Configuring basic system settings
Procedure
2. Click Accounts.
4. In the Full Name field, enter the full name of the user.
The RHEL web console automatically suggests a user name from the full name and fills it in the
User Name field. If you do not want to use the original naming convention consisting of the first
letter of the first name and the whole surname, update the suggestion.
5. In the Password/Confirm fields, enter the password and retype it for verification that your
password is correct. The color bar placed below the fields shows you security level of the
entered password, which does not allow you to create a user with a weak password.
6. Click Create to save the settings and close the dialog box.
48
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
Now you can see the new account in the Accounts settings and you can use the credentials to connect
to the system.
Activation of the kdump service is a part of the installation process, as described in Performing a
standard RHEL installation and Performing an advanced RHEL installation .
You can also use the web console to configure kdump. See Section 1.10.2, “Configuring kdump in the
RHEL 8 web console” for more information.
When kernel crash occurs, kdump uses kexec to boot into a second kernel, a capture kernel, which
resides in a reserved part of the system memory that is inaccessible to the first kernel. The second
kernel captures the contents of the crashed kernel’s memory, a crash dump, and saves it.
For more detailed information about kdump, see Managing, monitoring and updating the kernel .
For installing and configuring kdump, see Installing and configuring kdump .
49
Red Hat Enterprise Linux 8 Configuring basic system settings
WARNING
The kdump role replaces the kdump configuration of the managed hosts entirely. If
kdump role is applied, all previous kdump settings are lost, even if they are not
specified by the role variables. The /etc/sysconfig/kdump and /etc/kdump.conf
configuration files are replaced.
The following example shows how to apply the kdump role to set the location of the crash dump files:
Example 1.2. An example playbook applying the kdump role for setting the location of kdump
files
---
- hosts: kdump-test
vars:
kdump_path: /var/crash
roles:
- rhel-system-roles.kdump
50
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
For more information on applying the kdump role to manage various kdump configurations, see System
roles documentation.
Additionally, certain backup software enables you to integrate ReaR for disaster recovery.
# rear mkrescue
To make ReaR use its internal backup method, add these lines to the /etc/rear/local.conf file:
BACKUP=NETFS
BACKUP_URL=backup location
You can also configure ReaR to keep the previous backup archives when the new ones are created by
adding the following line to /etc/rear/local.conf:
51
Red Hat Enterprise Linux 8 Configuring basic system settings
NETFS_KEEP_OLD_BACKUP_COPY=y
To make the backups incremental, meaning that only the changed files are backed up on each run, add
this line to /etc/rear/local.conf:
BACKUP_TYPE=incremental
The systemd-journald daemon collects messages from various sources and forwards them to the
rsyslog service for further processing. The sources from which the messages are collected are:
Kernel
Syslog
The rsyslog service sorts the syslog messages by type and priority, and writes them to the files in the
/var/log directory, where the logs are persistently stored.
In the web console, use the Logs option if you want to inspect the log files.
Figure 1.6. Inspecting the log files in the RHEL 8 web console
52
CHAPTER 1. GETTING STARTED WITH SYSTEM ADMINISTRATION
Figure 1.6. Inspecting the log files in the RHEL 8 web console
Obtaining Red Hat support, in Section 1.13.1, “Obtaining Red Hat Support through Red Hat
Customer Portal”
Using the SOS report to troubleshoot problems, in Section 1.13.2, “Using the SOS report to
troubleshoot problems”
1.13.1. Obtaining Red Hat Support through Red Hat Customer Portal
By using the Red Hat Customer Portal you can:
Note that the SOS report is provided in the sos package, which is not installed with the default minimal
installation of Red Hat Enterprise Linux.
# sosreport
To attach the sos report to your support case, see the Red Hat Knowledgebase article How can I attach
53
Red Hat Enterprise Linux 8 Configuring basic system settings
To attach the sos report to your support case, see the Red Hat Knowledgebase article How can I attach
a file to a Red Hat support case?. Note that you will be prompted to enter the number of the support
case, when attaching the sos report.
For more information on SOS report, see the Red Hat Knowledgebase article What is a sosreport and
how to create one in Red Hat Enterprise Linux 4.6 and later?.
54
CHAPTER 2. MANAGING SOFTWARE PACKAGES
NOTE
Upstream documentation identifies the technology as DNF and the tool is referred to as
DNF in the upstream. As a result, some output returned by the new YUM tool in RHEL 8
mentions DNF.
Although YUM v4 used in RHEL 8 is based on DNF, it is compatible with YUM v3 used in RHEL 7. For
software installation, the yum command and most of its options work the same way in RHEL 8 as they
did in RHEL 7.
Selected yum plug-ins and utilities have been ported to the new DNF back end, and can be installed
under the same names as in RHEL 7. Packages also provide compatibility symlinks, so the binaries,
configuration files, and directories can be found in usual locations.
Note that the legacy Python API provided by YUM v3 is no longer available. You can migrate your plug-
ins and scripts to the new API provided by YUM v4 (DNF Python API), which is stable and fully
supported. See DNF API Reference for more information.
Components made available as Application Streams can be packaged as modules or RPM packages, and
are delivered through the AppStream repository in Red Hat Enterprise Linux 8. Each Application Stream
has a given life cycle, either the same as RHEL 8 or shorter, more suitable to the particular application.
Application Streams with a shorter life cycle are listed in the Red Hat Enterprise Linux 8 Application
Streams Life Cycle page.
Modules are collections of packages representing a logical unit: an application, a language stack, a
database, or a set of tools. These packages are built, tested, and released together.
Module streams represent versions of the Application Stream components. For example, two streams
(versions) of the PostgreSQL database server are available in the postgresql module: PostgreSQL 10
(the default stream) and PostgreSQL 9.6. Only one module stream can be installed on the system.
Different versions can be used in separate containers.
Detailed module commands are described in the Installing, managing, and removing user-space
components document. For a list of modules available in AppStream, see the Package manifest.
55
Red Hat Enterprise Linux 8 Configuring basic system settings
List packages.
List repositories.
Note that yum search command returns term matches within the name and summary of the
packages. This makes the search faster and enables you to search for packages you do not know
the name of, but for which you know a related term.
Replace term with a term you want to search for in a package name, summary, or description.
Note that yum search --all enables a more exhaustive but slower search.
To list all packages in all enabled repositories that are available to install, use:
Note that you can filter the results by appending global expressions as arguments. See Section 2.3.6,
“Specifying global expressions in yum input” for more details.
56
CHAPTER 2. MANAGING SOFTWARE PACKAGES
# yum repolist
# yum repoinfo
Note that you can filter the results by passing the ID or name of repositories as arguments or by
appending global expressions. See Section 2.3.6, “Specifying global expressions in yum input” for more
details.
Note that you can filter the results by appending global expressions as arguments. See Section 2.3.6,
“Specifying global expressions in yum input” for more details.
Note that you can filter the results by appending command line options for the yum group list
command (--hidden, --available). For more available options see the man pages.
Note that you can filter the results by appending global expressions as arguments. See Section 2.7.4,
“Specifying global expressions in yum input” for more details.
57
Red Hat Enterprise Linux 8 Configuring basic system settings
yum commands allow you to filter the results by appending one or more glob expressions as arguments.
Global expressions must be escaped when passed as arguments to the yum command. To ensure global
expressions are passed to yum as intended, use one of the following methods:
Escape the wildcard characters by preceding them with a backslash (\) character.
Install packages.
When installing packages on a multilib system (AMD64, Intel 64 machine), you can specify the
architecture of the package by appending it to the package name:
If you know the name of the binary you want to install, but not the package name, you can use
the path to the binary as an argument:
yum searches through the package lists, finds the package which provides /usr/sbin/binary-file,
58
CHAPTER 2. MANAGING SOFTWARE PACKAGES
yum searches through the package lists, finds the package which provides /usr/sbin/binary-file,
and prompts you as to whether you want to install it.
Note that you can optimize the package search by explicitly defining how to parse the argument. See
Section 2.4.3, “Specifying a package name in yum input” for more details.
Or
Replace group-name with the full name of the group or environmental group.
Replace name and architecture with the exact name and architecture of the package.
To install a package using it’s exact name, epoch, version, release, and architecture, use:
Replace name, epoch, version, release, and architecture with the exact name, epoch, version,
release, and architecture of the package.
59
Red Hat Enterprise Linux 8 Configuring basic system settings
# yum check-update
The output returns the list of packages and their dependencies that have an update available.
IMPORTANT
When applying updates to kernel, yum always installs a new kernel regardless of whether
you are using the yum update or yum install command.
# yum update
60
CHAPTER 2. MANAGING SOFTWARE PACKAGES
DNF Automatic is an alternative command-line interface to YUM that is suited for automatic and
regular execution using systemd timers, cron jobs and other such tools.
DNF Automatic synchronizes package metadata as needed and then checks for updates available.
After, the tool can perform one of the following actions depending on how you configure it:
Exit
The outcome of the operation is then reported by a selected mechanism, such as the standard output or
email.
The behavior of DNF Automatic is defined by its configuration file, which is by default the
/etc/dnf/automatic.conf file.
To run DNF Automatic, you always need to enable and start a specific systemd timer unit. You can use
one of the timer units provided in the dnf-automatic package, or you can write your own timer unit
depending on your needs.
dnf-automatic.timer
This timer unit behaves as the configuration file specifies with regards to downloading and
applying updates.
The timer units below override the configuration file with regards to downloading and applying
updates.
dnf-automatic-notifyonly.timer
Regardless of the configuration file settings, this timer unit only notifies you about available
updates.
dnf-automatic-download.timer
Regardless of the configuration file settings, this timer unit only downloads available updates,
61
Red Hat Enterprise Linux 8 Configuring basic system settings
Regardless of the configuration file settings, this timer unit only downloads available updates,
but does not install these updates.
dnf-automatic-install.timer
Regardless of the configuration file settings, this timer downloads and installs available updates.
By default, DNF Automatic uses /etc/dnf/automatic.conf as its configuration file to define its behavior.
[commands] section
Sets the mode of operation of DNF Automatic.
[emitters] section
Defines how the results of DNF Automatic are reported.
[command_email] section
Provides the email emitter configuration for an external command used to send email.
[email] section
Provides the email emitter configuration.
[base] section
Overrides settings from YUM’s main configuration file.
WARNING
Settings of the operation mode from the [commands] section are overridden by
settings used by a systemd timer unit for all timer units except dnf-automatic.timer.
With the default settings of /etc/dnf/automatic.conf, DNF Automatic checks for available updates,
downloads them, and reports the results as standard output.
Procedure
2. Enable and start the systemd timer unit that most closely fits your needs.
62
CHAPTER 2. MANAGING SOFTWARE PACKAGES
NOTE
Alternatively, you can also run DNF Automatic by executing the /usr/bin/dnf-automatic
file directly from the command line or from a custom script.
Remove packages.
NOTE
Note that you can optimize the package search by explicitly defining how to parse the argument. See
Section 2.6.3, “Specifying a package name in yum input” for more details.
63
Red Hat Enterprise Linux 8 Configuring basic system settings
Or
Replace name and architecture with the exact name and architecture of the package.
To install a package using it’s exact name, epoch, version, release, and architecture, use:
Replace name, epoch, version, release, and architecture with the exact name, epoch, version,
release, and architecture of the package.
64
CHAPTER 2. MANAGING SOFTWARE PACKAGES
Note that you can filter the results by appending command line options for the yum group list
command (--hidden, --available). For more available options see the man pages.
Note that you can filter the results by appending global expressions as arguments. See Section 2.7.4,
“Specifying global expressions in yum input” for more details.
Or
Replace group-name with the full name of the group or environmental group.
Or
65
Red Hat Enterprise Linux 8 Configuring basic system settings
Escape the wildcard characters by preceding them with a backslash (\) character.
List transactions.
Revert transactions.
Repeat transactions.
# yum history
To display a list of all the latest operations for a selected package, use:
Replace package-name with the name of the package. You can filter the command output by
appending global expressions. See Section 2.8.4, “Specifying global expressions in yum input”
for more details.
66
CHAPTER 2. MANAGING SOFTWARE PACKAGES
Note that the yum history undo command only reverts the steps that were performed during the
transaction. If the transaction installed a new package, the yum history undo command uninstalls it. If
the transaction uninstalled a package, the yum history undo command reinstalls it. yum history undo
also attempts to downgrade all updated packages to their previous versions, if the older packages are
still available.
Note that the yum history redo command only repeats the steps that were performed during the
transaction.
Escape the wildcard characters by preceding them with a backslash (\) character.
67
Red Hat Enterprise Linux 8 Configuring basic system settings
Note that the values you define in individual [repository] sections of the /etc/yum.conf file override
values set in the [main] section.
NOTE
Do not give custom repositories names used by the Red Hat repositories to avoid
conflicts.
For a complete list of available [repository] options, see the [repository] OPTIONS section of the
yum.conf(5) manual page.
NOTE
68
CHAPTER 2. MANAGING SOFTWARE PACKAGES
WARNING
To list available repository IDs, see Section 2.3.2, “Listing packages with yum”.
To list available repository IDs, see Section 2.3.2, “Listing packages with yum”.
69
Red Hat Enterprise Linux 8 Configuring basic system settings
You can add additional options under the [main] section heading in /etc/yum.conf.
For a complete list of available [main] options, see the [main] OPTIONS section of the yum.conf(5)
manual page.
The following section describes how to enable, configure, and disable yum plug-ins.
The plug-in configuration files always contain a [main] section where the enabled= option controls
whether the plug-in is enabled when you run yum commands. If this option is missing, you can add it
manually to the file.
Every installed plug-in has its own configuration file in the /etc/dnf/plugins/ directory. You can enable or
disable plug-in specific options in these files.
1. Ensure a line beginning with plugins= is present in the [main] section of the /etc/yum.conf
file.
plugins=1
1. Ensure a line beginning with plugins= is present in the [main] section of the /etc/yum.conf
file.
plugins=0
IMPORTANT
70
CHAPTER 2. MANAGING SOFTWARE PACKAGES
IMPORTANT
Disabling all plug-ins is not advised. Certain plug-ins provide important yum
services. In particular, the product-id and subscription-manager plug-ins
provide support for the certificate-based Content Delivery Network (CDN).
Disabling plug-ins globally is provided as a convenience option, and is
advisable only when diagnosing a potential problem with yum.
To disable all yum plug-ins for a particular command, append --noplugins option to the
command.
71
Red Hat Enterprise Linux 8 Configuring basic system settings
Systemd introduces the concept of systemd units. These units are represented by unit configuration
files located in one of the directories listed in the following table.
Directory Description
System services
Listening sockets
For a complete list of available systemd unit types, see the following table.
72
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
For example, to override the default value of the timeout limit, which is set to 90 seconds, use the
DefaultTimeoutStartSec parameter to input the required value in seconds.
DefaultTimeoutStartSec=required value
For further information, see Example 3.20, “Changing the timeout limit” .
Socket-based activation — At boot time, systemd creates listening sockets for all system
services that support this type of activation, and passes the sockets to these services as soon as
they are started. This not only allows systemd to start services in parallel, but also makes it
possible to restart a service without losing any message sent to it while it is unavailable: the
corresponding socket remains accessible and all messages are queued.
Systemd uses socket units for socket-based activation.
Bus-based activation — System services that use D-Bus for inter-process communication can
be started on-demand the first time a client application attempts to communicate with them.
Systemd uses D-Bus service files for bus-based activation.
Path-based activation — System services that support path-based activation can be started
73
Red Hat Enterprise Linux 8 Configuring basic system settings
Path-based activation — System services that support path-based activation can be started
on-demand when a particular file or directory changes its state. Systemd uses path units for
path-based activation.
Mount and automount point management — Systemd monitors and manages mount and
automount points. Systemd uses mount units for mount points and automount units for
automount points.
Aggressive parallelization — Because of the use of socket-based activation, systemd can start
system services in parallel as soon as all listening sockets are in place. In combination with
system services that support on-demand activation, parallel activation significantly reduces the
time required to boot the system.
Backwards compatibility with SysV init — Systemd supports SysV init scripts as described in
the Linux Standard Base Core Specification , which eases the upgrade path to systemd service
units.
Systemd has only limited support for runlevels. It provides a number of target units that can be
directly mapped to these runlevels and for compatibility reasons, it is also distributed with the
earlier runlevel command. Not all systemd targets can be directly mapped to runlevels,
however, and as a consequence, this command might return N to indicate an unknown runlevel.
It is recommended that you avoid using the runlevel command if possible.
For more information about systemd targets and their comparison with runlevels, see
Section 3.3, “Working with systemd targets” .
The systemctl utility does not support custom commands. In addition to standard commands
such as start, stop, and status, authors of SysV init scripts could implement support for any
number of arbitrary commands in order to provide additional functionality. For example, the init
script for iptables could be executed with the panic command, which immediately enabled
panic mode and reconfigured the system to start dropping all incoming and outgoing packets.
This is not supported in systemd and the systemctl only accepts documented commands.
For more information about the systemctl utility and its comparison with the earlier service
utility, see Table 3.3, “Comparison of the service utility with systemctl” .
The systemctl utility does not communicate with services that have not been started by
systemd. When systemd starts a system service, it stores the ID of its main process in order to
keep track of it. The systemctl utility then uses this PID to query and manage the service.
Consequently, if a user starts a particular daemon directly on the command line, systemctl is
unable to determine its current status or stop it.
Systemd stops only running services. Previously, when the shutdown sequence was initiated,
Red Hat Enterprise Linux 6 and earlier releases of the system used symbolic links located in the
/etc/rc0.d/ directory to stop all available system services regardless of their status. With
systemd , only running services are stopped on shutdown.
System services are unable to read from the standard input stream. When systemd starts a
74
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
System services are unable to read from the standard input stream. When systemd starts a
service, it connects its standard input to /dev/null to prevent any interaction with the user.
System services do not inherit any context (such as the HOME and PATH environment
variables) from the invoking user and their session. Each service runs in a clean execution
context.
When loading a SysV init script, systemd reads dependency information encoded in the Linux
Standard Base (LSB) header and interprets it at run time.
All operations on service units are subject to a default timeout of 5 minutes to prevent a
malfunctioning service from freezing the system. This value is hardcoded for services that are
generated from initscripts and cannot be changed. However, individual configuration files can
be used to specify a longer timeout value per service, see Example 3.20, “Changing the timeout
limit”.
For a detailed list of compatibility changes introduced with systemd, see the Migration Planning Guide
for Red Hat Enterprise Linux 7.
Service units end with the .service file extension and serve a similar purpose as init scripts. To view,
start, stop, restart, enable, or disable system services, use the systemctl command as described in
Comparison of the service utility with systemctl , Comparison of the chkconfig utility with systemctl , and
further in this section. The service and chkconfig commands are still available in the system and work
as expected, but are only included for compatibility reasons and should be avoided.
75
Red Hat Enterprise Linux 8 Configuring basic system settings
systemctl is-active
name.service
service --status-all systemctl list-units --type Displays the status of all services.
service --all
systemctl is-enabled
name.service
However, the file extension can be omitted, in which case the systemctl utility assumes the argument is
a service unit. The following command is equivalent to the one above:
Additionally, some units have alias names. Those names can have shorter names than units, which can be
used instead of the actual unit names. To find all aliases that can be used for a particular unit, use:
76
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
The exception to this are unit file commands such as the systemctl enable and systemctl disable
commands. These commands do not need a running system and do not affect running processes, but
they do affect unit files. Therefore, you can run these commands even in chroot environment. For
example, to enable the httpd service on a system under the /srv/website1/ directory:
# chroot /srv/website1
# systemctl enable httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service, pointing to
/usr/lib/systemd/system/httpd.service.
For each service unit file, this command displays its full name (UNIT) followed by a note whether the unit
file has been loaded (LOAD), its high-level ( ACTIVE) and low-level ( SUB) unit file activation state, and
a short description (DESCRIPTION).
By default, the systemctl list-units command displays only active units. If you want to list all loaded
units regardless of their state, run this command with the --all or -a command line option:
You can also list all available service units to see if they are enabled. To do so, type:
For each service unit, this command displays its full name (UNIT FILE) followed by information whether
the service unit is enabled or not (STATE). For information on how to determine the status of individual
service units, see Displaying service status.
To list all currently loaded service units, run the following command:
77
Red Hat Enterprise Linux 8 Configuring basic system settings
46 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'
To list all installed service unit files to determine if they are enabled, type:
Replace name with the name of the service unit you want to inspect (for example, gdm). This command
displays the name of the selected service unit followed by its short description, one or more fields
described in Table 3.5, “Available service unit information” , and if it is executed by the root user, also the
most recent log entries.
Field Description
78
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
Field Description
To only verify that a particular service unit is running, run the following command:
Note that both systemctl is-active and systemctl is-enabled return an exit status of 0 if the specified
service unit is running or enabled. For information on how to list all currently loaded service units, see
Listing services.
The service unit for the GNOME Display Manager is named gdm.service. To determine the current
status of this service unit, type the following at a shell prompt:
To determine what services are ordered to start before the specified service, type the following at a
shell prompt:
79
Red Hat Enterprise Linux 8 Configuring basic system settings
├─system.slice
├─systemd-journald.socket
├─systemd-user-sessions.service
└─basic.target
[output truncated]
To determine what services are ordered to start after the specified service, type the following at a
shell prompt:
Replace name with the name of the service unit you want to start (for example, gdm). This command
starts the selected service unit in the current session. For information on how to enable a service unit to
be started at boot time, see Enabling a service . For information on how to determine the status of a
certain service unit, see Displaying service status.
The service unit for the Apache HTTP Server is named httpd.service. To activate this service unit
and start the httpd daemon in the current session, run the following command as root:
Replace name with the name of the service unit you want to stop (for example, bluetooth). This
command stops the selected service unit in the current session. For information on how to disable a
80
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
service unit and prevent it from being started at boot time, see Disabling a service . For information on
how to determine the status of a certain service unit, see Displaying service status.
The service unit for the bluetoothd daemon is named bluetooth.service. To deactivate this service
unit and stop the bluetoothd daemon in the current session, run the following command as root:
Replace name with the name of the service unit you want to restart (for example, httpd). This command
stops the selected service unit in the current session and immediately starts it again. Importantly, if the
selected service unit is not running, this command starts it too. To tell systemd to restart a service unit
only if the corresponding service is already running, run the following command as root:
Certain system services also allow you to reload their configuration without interrupting their execution.
To do so, type as root:
Note that system services that do not support this feature ignore this command altogether. For
convenience, the systemctl command also supports the reload-or-restart and reload-or-try-restart
commands that restart such services instead. For information on how to determine the status of a
certain service unit, see Displaying service status.
In order to prevent users from encountering unnecessary error messages or partially rendered web
pages, the Apache HTTP Server allows you to edit and reload its configuration without the need to
restart it and interrupt actively processed requests. To do so, type the following at a shell prompt as
root:
81
Red Hat Enterprise Linux 8 Configuring basic system settings
Replace name with the name of the service unit you want to enable (for example, httpd). This command
reads the [Install] section of the selected service unit and creates appropriate symbolic links to the
/usr/lib/systemd/system/name.service file in the /etc/systemd/system/ directory and its
subdirectories. This command does not, however, rewrite links that already exist. If you want to ensure
that the symbolic links are re-created, use the following command as root:
This command disables the selected service unit and immediately enables it again. For information on
how to determine whether a certain service unit is enabled to start at boot time, see Displaying service
status. For information on how to start a service in the current session, see Starting a service .
To configure the Apache HTTP Server to start automatically at boot time, run the following
command as root:
Replace name with the name of the service unit you want to disable (for example, bluetooth). This
command reads the [Install] section of the selected service unit and removes appropriate symbolic links
to the /usr/lib/systemd/system/name.service file from the /etc/systemd/system/ directory and its
subdirectories. In addition, you can mask any service unit to prevent it from being started manually or by
another service. To do so, run the following command as root:
This command replaces the /etc/systemd/system/name.service file with a symbolic link to /dev/null,
rendering the actual unit file inaccessible to systemd. To revert this action and unmask a service unit,
type as root:
For information on how to determine whether a certain service unit is enabled to start at boot time, see
Displaying service status. For information on how to stop a service in the current session, see Stopping a
service.
Example 3.6, “Stopping a service” illustrates how to stop the bluetooth.service unit in the current
session. To prevent this service unit from starting at boot time, type the following at a shell prompt
as root:
82
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
When you attempt to start a new service, systemd resolves all dependencies automatically. Note that
this is done without explicit notification to the user. If you are already running a service, and you attempt
to start another service with a negative dependency, the first service is automatically stopped.
For example, if you are running the postfix service, and you try to start the sendmail service, systemd
first automatically stops postfix, because these two services are conflicting and cannot run on the same
port.
Systemd targets are represented by target units. Target units end with the .target file extension and
their only purpose is to group together other systemd units through a chain of dependencies. For
example, the graphical.target unit, which is used to start a graphical session, starts system services such
as the GNOME Display Manager (gdm.service) or Accounts Service (accounts-daemon.service) and
also activates the multi-user.target unit. Similarly, the multi-user.target unit starts other essential
system services such as NetworkManager (NetworkManager.service) or D-Bus (dbus.service) and
activates another target unit named basic.target.
Red Hat Enterprise Linux 7 was distributed with a number of predefined targets that are more or less
similar to the standard set of runlevels from the previous releases of this system. For compatibility
reasons, it also provides aliases for these targets that directly map them to SysV runlevels. Table 3.6,
“Comparison of SysV runlevels with systemd targets” provides a complete list of SysV runlevels and
their corresponding systemd targets.
83
Red Hat Enterprise Linux 8 Configuring basic system settings
To view, change, or configure systemd targets, use the systemctl utility as described in Table 3.7,
“Comparison of SysV init commands with systemctl” and in the sections below. The runlevel and telinit
commands are still available in the system and work as expected, but are only included for compatibility
reasons and should be avoided.
systemctl get-default
This command resolves the symbolic link located at /etc/systemd/system/default.target and displays
the result.
$ systemctl get-default
graphical.target
84
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
For each target unit, this commands displays its full name (UNIT) followed by a note whether the unit has
been loaded (LOAD), its high-level ( ACTIVE) and low-level ( SUB) unit activation state, and a short
description (DESCRIPTION).
By default, the systemctl list-units command displays only active units. If you want to list all loaded
units regardless of their state, run this command with the --all or -a command line option:
17 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
Replace name with the name of the target unit you want to use by default (for example, multi-user).
This command replaces the /etc/systemd/system/default.target file with a symbolic link to
/usr/lib/systemd/system/name.target, where name is the name of the target unit you want to use.
85
Red Hat Enterprise Linux 8 Configuring basic system settings
To configure the system to use the multi-user.target unit by default, run the following command as
root:
Replace name with the name of the target unit you want to use (for example, multi-user). This
command starts the target unit named name and all dependent units, and immediately stops all others.
To turn off the graphical user interface and change to the multi-user.target unit in the current
session, run the following command as root:
To change the current target and enter rescue mode in the current session, type the following at a shell
prompt as root:
systemctl rescue
This command is similar to systemctl isolate rescue.target, but it also sends an informative message to
all users that are currently logged into the system. To prevent systemd from sending this message, run
this command with the --no-wall command line option:
For information on how to enter emergency mode, see Section 3.3.6, “Changing to emergency mode” .
To enter rescue mode in the current session, run the following command as root:
86
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
# systemctl rescue
To change the current target and enter emergency mode, type the following at a shell prompt as root:
systemctl emergency
This command is similar to systemctl isolate emergency.target, but it also sends an informative
message to all users that are currently logged into the system. To prevent systemd from sending this
message, run this command with the --no-wall command line option:
For information on how to enter rescue mode, see Section 3.3.5, “Changing to rescue mode” .
To enter emergency mode without sending a message to all users that are currently logged into the
system, run the following command as root:
87
Red Hat Enterprise Linux 8 Configuring basic system settings
systemctl poweroff
To shut down and halt the system without powering off the machine, run the following command as
root:
systemctl halt
By default, running either of these commands causes systemd to send an informative message to all
users that are currently logged into the system. To prevent systemd from sending this message, run the
selected command with the --no-wall command line option, for example:
Where hh:mm is the time in 24 hour clock format. The /run/nologin file is created 5 minutes before
system shutdown to prevent new logins. When a time argument is used, an optional message, the wall
message, can be appended to the command.
To shut down and halt the system after a delay, without powering off the machine, use a command in
the following format as root:
shutdown --halt +m
88
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
Where +m is the delay time in minutes. The now keyword is an alias for +0.
shutdown -c
systemctl reboot
By default, this command causes systemd to send an informative message to all users that are currently
logged into the system. To prevent systemd from sending this message, run this command with the --
no-wall command line option:
systemctl suspend
This command saves the system state in RAM and with the exception of the RAM module, powers off
most of the devices in the machine. When you turn the machine back on, the system then restores its
state from RAM without having to boot again. Because the system state is saved in RAM and not on the
hard disk, restoring the system from suspend mode is significantly faster than restoring it from
hibernation, but as a consequence, a suspended system state is also vulnerable to power outages.
For information on how to hibernate the system, see Section 3.4.4, “Hibernating the system”.
systemctl hibernate
This command saves the system state on the hard disk drive and powers off the machine. When you turn
the machine back on, the system then restores its state from the saved data without having to boot
again. Because the system state is saved on the hard disk and not in RAM, the machine does not have to
maintain electrical power to the RAM module, but as a consequence, restoring the system from
hibernation is significantly slower than restoring it from suspend mode.
To hibernate and suspend the system, run the following command as root:
systemctl hybrid-sleep
For information on how to suspend the system, see Section 3.4.3, “Suspending the system”.
89
Red Hat Enterprise Linux 8 Configuring basic system settings
unit_name.type_extension
Here, unit_name stands for the name of the unit and type_extension identifies the unit type, see
Table 3.2, “Available systemd unit types” for a complete list of unit types. For example, there usually is
sshd.service as well as sshd.socket unit present on your system.
Unit files can be supplemented with a directory for additional configuration files. For example, to add
custom configuration options to sshd.service, create the sshd.service.d/custom.conf file and insert
additional directives there. For more information on configuration directories, see Section 3.5.4,
“Modifying existing unit files”.
Many unit file options can be set using the so called unit specifiers – wildcard strings that are
dynamically replaced with unit parameters when the unit file is loaded. This enables creation of generic
unit files that serve as templates for generating instantiated units. See Section 3.5.5, “Working with
instantiated units” for details.
The [Unit] section — contains generic options that are not dependent on the type of the unit.
These options provide unit description, specify the unit’s behavior, and set dependencies to
other units. For a list of most frequently used [Unit] options, see Table 3.9, “Important [Unit]
section options”.
The [Unit type] section — if a unit has type-specific directives, these are grouped under a
section named after the unit type. For example, service unit files contain the [Service] section.
The [Install] section — contains information about unit installation used by systemctl enable
and disable commands. For a list of options for the [Install] section, see Table 3.11, “Important
[Install] section options”.
90
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
After [b] Defines the order in which units are started. The unit
starts only after the units specified in After are
active. Unlike Requires, After does not explicitly
activate the specified units. The Before option has
the opposite functionality to After .
[b] In most cases, it is sufficient to set only the ordering dependencies with After and Before unit file options. If you also
set a requirement dependency with Wants (recommended) or Requires, the ordering dependency still needs to be
specified. That is because ordering and requirement dependencies work independently from each other.
91
Red Hat Enterprise Linux 8 Configuring basic system settings
92
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
RequiredBy A list of units that depend on the unit. When this unit
is enabled, the units listed in RequiredBy gain a
Require dependency on the unit.
A whole range of options that can be used to fine tune the unit configuration. The below example shows
a service unit installed on the system. Moreover, unit file options can be defined in a way that enables
dynamic creation of units as described in Working with instantiated units .
[Unit]
Description=Postfix Mail Transport Agent
After=syslog.target network.target
Conflicts=sendmail.service exim.service
[Service]
Type=forking
PIDFile=/var/spool/postfix/pid/master.pid
93
Red Hat Enterprise Linux 8 Configuring basic system settings
EnvironmentFile=-/etc/sysconfig/network
ExecStartPre=-/usr/libexec/postfix/aliasesdb
ExecStartPre=-/usr/libexec/postfix/chroot-update
ExecStart=/usr/sbin/postfix start
ExecReload=/usr/sbin/postfix reload
ExecStop=/usr/sbin/postfix stop
[Install]
WantedBy=multi-user.target
The [Unit] section describes the service, specifies the ordering dependencies, as well as conflicting
units. In [Service], a sequence of custom scripts is specified to be executed during unit activation, on
stop, and on reload. EnvironmentFile points to the location where environment variables for the
service are defined, PIDFile specifies a stable PID for the main process of the service. Finally, the
[Install] section lists units that depend on the service.
1. Prepare the executable file with the custom service. This can be a custom-created script, or an
executable delivered by a software provider. If required, prepare a PID file to hold a constant
PID for the main process of the custom service. It is also possible to include environment files to
store shell variables for the service. Make sure the source script is executable (by executing the
chmod a+x) and is not interactive.
2. Create a unit file in the /etc/systemd/system/ directory and make sure it has correct file
permissions. Execute as root:
touch /etc/systemd/system/name.service
Replace name with a name of the service to be created. Note that file does not need to be
executable.
3. Open the name.service file created in the previous step, and add the service configuration
options. There is a variety of options that can be used depending on the type of service you wish
to create, see Section 3.5.1, “Understanding the unit file structure” . The following is an example
unit configuration for a network-related service:
[Unit]
Description=service_description
After=network.target
[Service]
ExecStart=path_to_executable
Type=forking
PIDFile=path_to_pidfile
94
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
[Install]
WantedBy=default.target
Where:
the After setting ensures that the service is started only after the network is running. Add a
space-separated list of other relevant services or targets.
Type=forking is used for daemons that make the fork system call. The main process of the
service is created with the PID specified in path_to_pidfile. Find other startup types in
Table 3.10, “Important [Service] section options” .
WantedBy states the target or targets that the service should be started under. Think of
these targets as of a replacement of the older concept of runlevels, see Section 3.3,
“Working with systemd targets” for details.
4. Notify systemd that a new name.service file exists by executing the following command as
root:
systemctl daemon-reload
WARNING
When using the Emacs text editor, it is often faster and more convenient to have it running in the
background instead of starting a new instance of the program whenever editing a file. The following
steps show how to create a unit file for Emacs, so that it can be handled like a service.
1. Create a unit file in the /etc/systemd/system/ directory and make sure it has the correct file
permissions. Execute as root:
# touch /etc/systemd/system/emacs.service
95
Red Hat Enterprise Linux 8 Configuring basic system settings
[Unit]
Description=Emacs: the extensible, self-documenting text editor
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=always
[Install]
WantedBy=default.target
With the above configuration, the /usr/bin/emacs executable is started in daemon mode on
service start. The SSH_AUTH_SOCK environment variable is set using the "%t" unit specifier
that stands for the runtime directory. The service also restarts the emacs process if it exits
unexpectedly.
3. Execute the following commands to reload the configuration and start the custom service:
# systemctl daemon-reload
As the editor is now registered as a systemd service, you can use all standard systemctl commands.
For example, run systemctl status emacs to display the editor’s status or systemctl enable emacs
to make the editor start automatically on system boot.
System Administrators often need to configure and run multiple instances of a service. This is done
by creating copies of the original service configuration files and modifying certain parameters to
avoid conflicts with the primary instance of the service. The following procedure shows how to
create a second instance of the sshd service:
1. Create a copy of the sshd_config file that will be used by the second daemon:
# cp /etc/ssh/sshd{,-second}_config
2. Edit the sshd-second_config file created in the previous step to assign a different port
number and PID file to the second daemon:
Port 22220
PidFile /var/run/sshd-second.pid
See the sshd_config(5) manual page for more information on Port and PidFile options.
Make sure the port you choose is not in use by any other service. The PID file does not have
to exist before running the service, it is generated automatically on service start.
3. Create a copy of the systemd unit file for the sshd service:
96
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
# cp /usr/lib/systemd/system/sshd.service /etc/systemd/system/sshd-second.service
b. Add sshd.service to services specified in the After option, so that the second instance
starts only after the first one has already started:
c. The first instance of sshd includes key generation, therefore remove the
ExecStartPre=/usr/sbin/sshd-keygen line.
[Unit]
Description=OpenSSH server second instance daemon
After=syslog.target network.target auditd.service sshd.service
[Service]
EnvironmentFile=/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -D -f /etc/ssh/sshd-second_config $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
5. If using SELinux, add the port for the second instance of sshd to SSH ports, otherwise the
second instance of sshd will be rejected to bind to the port:
Verify if the sshd-second.service is running by using the systemctl status command. Also,
verify if the port is enabled correctly by connecting to the service:
If the firewall is in use, make sure that it is configured appropriately in order to allow
97
Red Hat Enterprise Linux 8 Configuring basic system settings
If the firewall is in use, make sure that it is configured appropriately in order to allow
connections to the second instance of sshd.
To learn how to properly choose a target for ordering and dependencies of your custom unit files,
see the following articles
How to write a service unit file which enforces that particular services have to be started
How to decide what dependencies a systemd service unit definition should have
Additional information with some real-world examples of cases triggered by the ordering and
dependencies in a unit file is available in Red Hat Knowledgebase article Is there any useful information
about writing unit files?
If you want to set limits for services started by systemd, see the Red Hat Knowledgebase article How to
set limits for services in RHEL 7 and systemd. These limits need to be set in the service’s unit file. Note
that systemd ignores limits set in the /etc/security/limits.conf and /etc/security/limits.d/*.conf
configuration files. The limits defined in these files are set by PAM when starting a login session, but
daemons started by systemd do not use PAM login sessions.
Converting an init script to a unit file requires analyzing the script and extracting the necessary
information from it. Based on this data you can create a unit file. As init scripts can vary greatly
depending on the type of the service, you might need to employ more configuration options for
translation than outlined in this chapter. Note that some levels of customization that were available with
init scripts are no longer supported by systemd units.
The majority of information needed for conversion is provided in the script’s header. The following
example shows the opening section of the init script used to start the postfix service on Red Hat
Enterprise Linux 6:
!/bin/bash # postfix Postfix Mail Transfer Agent # chkconfig: 2345 80 30 # description: Postfix is a Mail
Transport Agent, which is the program that moves mail from one machine to another. # processname:
master # pidfile: /var/spool/postfix/pid/master.pid # config: /etc/postfix/main.cf # config:
/etc/postfix/master.cf BEGIN INIT INFO # Provides: postfix MTA # Required-Start: $local_fs $network
$remote_fs # Required-Stop: $local_fs $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0
1 6 # Short-Description: start and stop postfix # Description: Postfix is a Mail Transport Agent, which
is the program that moves mail from one machine to another. # END INIT INFO
In the above example, only lines starting with # chkconfig and # description are mandatory, so you
might not find the rest in different init files. The text enclosed between the BEGIN INIT INFO and END
INIT INFO lines is called Linux Standard Base (LSB) header. If specified, LSB headers contain
directives defining the service description, dependencies, and default runlevels. What follows is an
overview of analytic tasks aiming to collect the data needed for a new unit file. The postfix init script is
used as an example, see the resulting postfix unit file in Example 3.16, “postfix.service unit file” .
Find descriptive information about the script on the line starting with #description. Use this description
98
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
Find descriptive information about the script on the line starting with #description. Use this description
together with the service name in the Description option in the [Unit] section of the unit file. The LSB
header might contain similar data on the #Short-Description and #Description lines.
The other two values specified on the #chkconfig line represent startup and shutdown priorities of the
init script. These values are interpreted by systemd if it loads the init script, but there is no unit file
equivalent.
99
Red Hat Enterprise Linux 8 Configuring basic system settings
The key information that is not included in the init script header is the path to the service executable,
and potentially some other files required by the service. In previous versions of Red Hat Enterprise Linux,
init scripts used a Bash case statement to define the behavior of the service on default actions, such as
start, stop, or restart, as well as custom-defined actions. The following excerpt from the postfix init
script shows the block of code to be executed at service start.
conf_check() {
[ -x /usr/sbin/postfix ] || exit 5
[ -d /etc/postfix ] || exit 6
[ -d /var/spool/postfix ] || exit 5
}
make_aliasesdb() {
if [ "$(/usr/sbin/postconf -h alias_database)" == "hash:/etc/aliases" ]
then
# /etc/aliases.db might be used by other MTA, make sure nothing
# has touched it since our last newaliases call
[ /etc/aliases -nt /etc/aliases.db ] ||
[ "$ALIASESDB_STAMP" -nt /etc/aliases.db ] ||
[ "$ALIASESDB_STAMP" -ot /etc/aliases.db ] || return
/usr/bin/newaliases
touch -r /etc/aliases.db "$ALIASESDB_STAMP"
else
/usr/bin/newaliases
fi
}
start() {
[ "$EUID" != "0" ] && exit 4
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1
conf_check
# Start daemons.
echo -n $"Starting postfix: "
make_aliasesdb >/dev/null 2>&1
[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $lockfile
echo
return $RETVAL
}
The extensibility of the init script allowed specifying two custom functions, conf_check() and
make_aliasesdb(), that are called from the start() function block. On closer look, several external files
and directories are mentioned in the above code: the main service executable /usr/sbin/postfix, the
/etc/postfix/ and /var/spool/postfix/ configuration directories, as well as the /usr/sbin/postconf/
directory.
Systemd supports only the predefined actions, but enables executing custom executables with
100
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
Converting complex init scripts requires understanding the purpose of every statement in the script.
Some of the statements are specific to the operating system version, therefore you do not need to
translate them. On the other hand, some adjustments might be needed in the new environment, both in
unit file as well as in the service executable and supporting files.
In order to return to the default configuration of the unit, just delete custom-created configuration files
in /etc/systemd/system/. To apply changes to unit files without rebooting the system, execute:
systemctl daemon-reload
The daemon-reload option reloads all unit files and recreates the entire dependency tree, which is
needed to immediately apply any change to a unit file. As an alternative, you can achieve the same result
with the following command, which must be executed under the root user:
init q
Also, if the modified unit file belongs to a running service, this service must be restarted to accept new
settings:
IMPORTANT
101
Red Hat Enterprise Linux 8 Configuring basic system settings
IMPORTANT
For example, to extend the configuration of the network service, do not modify the
/etc/rc.d/init.d/network initscript file. Instead, create new directory
/etc/systemd/system/network.service.d/ and a systemd drop-in file
/etc/systemd/system/network.service.d/my_config.conf. Then, put the modified values
into the drop-in file. Note: systemd knows the network service as network.service,
which is why the created directory must be called network.service.d
mkdir /etc/systemd/system/name.service.d/
Replace name with the name of the service you want to extend. The above syntax applies to all unit
types.
Create a configuration file in the directory made in the previous step. Note that the file name must end
with the .conf suffix. Type:
touch /etc/systemd/system/name.service.d/config_name.conf
Replace config_name with the name of the configuration file. This file adheres to the normal unit file
structure, therefore all directives must be specified under appropriate sections, see Section 3.5.1,
“Understanding the unit file structure”.
For example, to add a custom dependency, create a configuration file with the following content:
[Unit]
Requires=new_dependency
After=new_dependency
Where new_dependency stands for the unit to be marked as a dependency. Another example is a
configuration file that restarts the service after its main process exited, with a delay of 30 seconds:
[Service]
Restart=always
RestartSec=30
It is recommended to create small configuration files focused only on one task. Such files can be easily
moved or linked to configuration directories of other services.
systemctl daemon-reload
systemctl restart name.service
102
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
To modify the httpd.service unit so that a custom shell script is automatically executed when starting
the Apache service, perform the following steps. First, create a directory and a custom configuration
file:
# mkdir /etc/systemd/system/httpd.service.d/
# touch /etc/systemd/system/httpd.service.d/custom_script.conf
Provided that the script you want to start automatically with Apache is located at
/usr/local/bin/custom.sh, insert the following text to the custom_script.conf file:
[Service]
ExecStartPost=/usr/local/bin/custom.sh
# systemctl daemon-reload
NOTE
cp /usr/lib/systemd/system/name.service /etc/systemd/system/name.service
Where name stands for the name of the service unit you wish to modify. The above syntax applies to all
unit types.
Open the copied file with a text editor, and make the desired changes. To apply the unit changes,
execute as root:
systemctl daemon-reload
systemctl restart name.service
You can specify a timeout value per service to prevent a malfunctioning service from freezing the
103
Red Hat Enterprise Linux 8 Configuring basic system settings
You can specify a timeout value per service to prevent a malfunctioning service from freezing the
system. Otherwise, timeout is set by default to 90 seconds for normal services and to 300 seconds
for SysV-compatible services.
cp /usr/lib/systemd/system/httpd.service /etc/systemd/system/httpd.service
…
[Service]
…
PrivateTmp=true
TimeoutStartSec=10
[Install]
WantedBy=multi-user.target
…
systemctl daemon-reload
NOTE
systemd-delta
For example, the output of the above command can look as follows:
104
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
-TimeoutSec=180
+TimeoutSec=240
+Restart=Always
[Install]
WantedBy=multi-user.target
Table 3.13, “systemd-delta difference types” lists override types that can appear in the output of
systemd-delta. Note that if a file is overridden, systemd-delta by default displays a summary of
changes similar to the output of the diff command.
Type Description
It is good practice to run systemd-delta after system update to check if there are any updates to the
default units that are currently overridden by custom configuration. It is also possible to limit the output
only to a certain difference type. For example, to view just the overridden units, execute:
systemd-delta --type=overridden
If you want to edit a unit file and automatically create a drop-in file with the submitted changes, use the
following command:
To dump the unit configuration applying all overrides and drop-ins, use this command:
105
Red Hat Enterprise Linux 8 Configuring basic system settings
Replace the unit_name.type_extension by the name of the required unit and its type, for example
tuned.service.
template_name@instance_name.service
Where template_name stands for the name of the template configuration file. Replace instance_name
with the name for the unit instance. Several instances can point to the same template file with
configuration options common for all instances of the unit. Template unit name has the form of:
unit_name@.service
Wants=getty@ttyA.service getty@ttyB.service
first makes systemd search for given service units. If no such units are found, the part between "@" and
the type suffix is ignored and systemd searches for the getty@.service file, reads the configuration
from it, and starts the services.
Wildcard characters, called unit specifiers, can be used in any unit configuration file. Unit specifiers
substitute certain unit parameters and are interpreted at runtime. Table 3.14, “Important unit specifiers”
lists unit specifiers that are particularly useful for template units.
106
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
For a complete list of unit specifiers, see the systemd.unit(5) manual page.
[Unit]
Description=Getty on %I
…
[Service]
ExecStart=-/sbin/agetty --noclear %I $TERM
…
When the getty@ttyA.service and getty@ttyB.service are instantiated form the above template,
Description= is resolved as Getty on ttyA and Getty on ttyB.
The purpose of systemd units enabled by default, and circumstances under which you can safely
disable such systemd units in order to shorten the boot time.
For a complete list and detailed description of all options, see the systemd-analyze man page.
Prerequisites
Before starting to examine systemd in order to tune the boot time, you may want to list all enabled
services:
107
Red Hat Enterprise Linux 8 Configuring basic system settings
Procedure
For the overall information about the time that the last successful boot took, use:
$ systemd-analyze
Procedure
For the information about the initialization time of each systemd unit, use:
$ systemd-analyze blame
The output lists the units in descending order according to the time they took to initialize during the last
successful boot.
Procedure
To identify the units that took most time to initialize at the last successful boot, use:
$ systemd-analyze critical-chain
The output highlights the units that critically slow down the boot with the red color.
108
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
However, certain services must stay enabled in order that your operating system is safe and functions in
the way you need.
You can use the table below as a guide to selecting the services that you can safely disable. The table
lists all services enabled by default on a minimal installation of Red Hat Enterprise Linux 8, and for each
service it states whether this service can be safely disabled.
The table also provides more information about the circumstances under which the service can be
disabled, or the reason why you should not disable the service.
auditd.servic yes Disable auditd.service only if you do not need audit messages
e from the kernel. Be aware that if you disable auditd.service, the
/var/log/audit/audit.log file is not produced. Consequently, you
are not able to retroactively review some commonly-reviewed
actions or events, such as user logins, service starts or password
changes. Also note that auditd has two parts: a kernel part, and a
service itself. By using the systemctl disable auditd command,
you only disable the service, but not the kernel part. To disable
system auditing in its entirety, set audit=0 on kernel command
line.
autovt@.servi no This service runs only when it is really needed, so it does not need
ce to be disabled.
crond.service yes Be aware that no items from crontab will run if you disable
crond.service.
109
Red Hat Enterprise Linux 8 Configuring basic system settings
getty@.servic no This service runs only when it is really needed, so it does not need
e to be disabled.
irqbalance.se yes Disable irqbalance.service only if you have just one CPU. Do not
rvice disable irqbalance.service on systems with multiple CPUs.
kdump.servic yes Disable kdump.service only if you do not need reports from
e kernel crashes.
110
CHAPTER 3. MANAGING SERVICES WITH SYSTEMD
rhsmcertd.se no
rvice
rngd.service yes Disable rngd.service only if you do not need a lot of entropy on
your system, or you do not have any sort of hardware generator.
Note that the service is necessary in environments that require a
lot of good entropy, such as systems used for generation of X.509
certificates (for example the FreeIPA server).
rsyslog.servic yes Disable rsyslog.service only if you do not need persistent logs,
e or you set systemd-journald to persistent mode.
sshd.service yes Disable sshd.service only if you do not need remote logins by
OpenSSH server.
sssd.service yes Disable sssd.service only if there are no users who log in the
system over the network (for example by using LDAP or Kerberos).
Red Hat recommends to disable all sssd-* units if you disable
sssd.service.
111
Red Hat Enterprise Linux 8 Configuring basic system settings
To find more information about a service, you can run one of the following commands:
The systemctl cat command provides the content of the service file located under
/usr/lib/systemd/system/<service>, as well as all applicable overrides. The applicable overrides include
unit file overrides from the /etc/systemd/system/<service> file or drop-in files from a corresponding
unit.type.d directory.
For more information on drop-in files, see the systemd.unit man page.
The systemctl help command shows the man page of the particular service.
systemd(1) — The manual page for the systemd system and service manager provides more
information about its concepts and documents available command line options and
environment variables, supported configuration files and directories, recognized signals, and
available kernel options.
systemd-delta(1) — The manual page for the systemd-delta utility that allows to find extended
and overridden configuration files.
systemd.unit(5) — The manual page named systemd.unit provides detailed information about
systemd unit files and documents all available configuration options.
systemd.target(5) — The manual page named systemd.target documents the format of target
unit files.
systemd.kill(5) — The manual page named systemd.kill documents the configuration of the
process killing procedure.
112
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
Each user is associated with a unique numerical identification number called a user ID (UID). Likewise,
each group is associated with a group ID (GID). A user who creates a file is also the owner and group
owner of that file. The file is assigned separate read, write, and execute permissions for the owner, the
group, and everyone else. The file owner can be changed only by root, and access permissions can be
changed by both the root user and file owner.
cat /usr/share/doc/setup*/uidgid
The recommended practice is to assign IDs starting at 5,000 that were not already reserved, as the
reserved range can increase in the future. To make the IDs assigned to new users by default start at
5,000, change the UID_MIN and GID_MIN directives in the /etc/login.defs file:
NOTE
For users created before you changed UID_MIN and GID_MIN directives, UIDs will still
start at the default 1000.
Even with new user and group IDs beginning with 5,000, it is recommended not to raise IDs reserved by
the system above 1000 to avoid conflict with systems that retain the 1000 limit.
User private groups make it safe to set default permissions for a newly created file or directory, allowing
113
Red Hat Enterprise Linux 8 Configuring basic system settings
User private groups make it safe to set default permissions for a newly created file or directory, allowing
both the user and the group of that user to make modifications to the file or directory.
The setting which determines what permissions are applied to a newly created file or directory is called a
umask and is configured in the /etc/bashrc file. Traditionally on UNIX-based systems, the umask is set
to 022, which allows only the user who created the file or directory to make modifications. Under this
scheme, all other users, including members of the creator’s group, are not allowed to make any
modifications. However, under the UPG scheme, this "group protection" is not necessary since every
user has their own private group.
Procedure
1. Enter the Activities Overview by pressing the Press the Super key.
The Super key appears in a variety of options, depending on the keyboard and other hardware,
but often as either the Windows or Command key, and typically to the left of the Space bar.
Alternatively, you can open the Users utility from the Settings menu after clicking your user name in the
top right corner of the screen.
114
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
Prerequisites
To be able to make changes to the user accounts, first select the Unlock button, and
authenticate yourself as indicated by the dialog box that appears.
Note that unless you have superuser privileges, the application will prompt you to authenticate
as root.
Prerequisites
Open the Users settings tool as described in Section 4.4.1, “Opening the Users settings tool” .
Procedure
Prerequisites
Open the Users settings tool as described in Section 4.4.1, “Opening the Users settings tool” .
Procedure
4.4.2.3. Adding a user to the wheel group with the Users settings tool
Prerequisites
Open the Users settings tool as described in Section 4.4.1, “Opening the Users settings tool” .
Procedure
To add a user to the administrative group wheel, change the Account Type from Standard to
Administrator.
Prerequisites
Open the Users settings tool as described in Section 4.4.1, “Opening the Users settings tool” .
Procedure
To edit a user’s language setting, select the language and a drop-down menu appears.
115
Red Hat Enterprise Linux 8 Configuring basic system settings
When a new user is created, the account is disabled until a password is set.
The Password drop-down menu, shown in Figure 4.2, “The Password Menu” , contains the options to:
Utilities Description
116
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
useradd, usermod, userdel Standard utilities for adding, modifying, and deleting
user accounts.
groupadd , groupmod, groupdel Standard utilities for adding, modifying, and deleting
groups.
grpconv, grpunconv Similar to the previous, these utilities can be used for
conversion of shadowed information for group
accounts.
Procedure
Here options are command-line options for the useradd command. For more details, see the
useradd man page.
WARNING
With RHEL 8, you cannot use all-numeric user names. The reason for not allowing
such names is that this can confuse tools that work with user names and user ids,
which are numbers.
117
Red Hat Enterprise Linux 8 Configuring basic system settings
Procedure
# passwd username
This section provides the command-line options for useradd that cover the most common use cases.
Option Description
The default range of IDs for system and normal users has been changed in Red Hat Enterprise Linux 7
from earlier releases. Before Red Hat Enterprise Linux 7, UID 1-499 was used for system users and
values above for normal users. The default range for system users is now 1-999.
This change might cause problems when migrating to Red Hat Enterprise Linux 8 with existing users
having UIDs and GIDs between 500 and 999. The default ranges of UID and GID can be changed in the
/etc/login.defs file.
118
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
To add a new group of users to the system, use the following procedure.
Procedure
Here options are command-line options for the groupadd command. For more details, see the
groupadd man page.
WARNING
With RHEL 8, you cannot use all-numeric group names. The reason for not allowing
such names is that this can confuse tools that work with group names and group
ids, which are numbers.
Various options of usermod have different impact on user’s primary group and on their supplementary
groups.
Procedure
119
Red Hat Enterprise Linux 8 Configuring basic system settings
Procedure
Note that all previous supplementary groups of the user are replaced by the new group or several new
groups.
To add one or more groups to user’s supplementary groups, use this procedure:
Procedure
With this traditional scheme, file management is difficult; when someone creates a file, it is associated
with the primary group to which they belong. When a single person works on multiple projects, it
becomes difficult to associate the right files with the right group.
However, with the UPG scheme, groups are automatically assigned to files created within a directory
with the setgid bit set. The setgid bit makes managing group projects that share a common directory
very simple because any files a user creates within the directory are owned by the group that owns the
directory.
This section provides an example use case where creation of a group directory is needed.
In this example use case, a group of people need to work on files in the /opt/myproject/ directory. Some
people are trusted to modify the contents of this directory, but not everyone.
To create the group directory for this case, use this procedure.
Procedure
# mkdir /opt/myproject
120
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
# groupadd myproject
3. Associate the contents of the /opt/myproject/ directory with the myproject group:
4. Allow users in the group to create files within the directory and set the setgid bit:
At this point, all members of the myproject group can create and edit files in the
/opt/myproject/ directory without the administrator having to change file permissions every
time users write new files. To verify that the permissions have been set correctly, run the
following command:
# ls -ld /opt/myproject
drwxrwsr-x. 3 root myproject 4096 Mar 3 18:31 /opt/myproject
Only users listed in the /etc/sudoers configuration file are allowed to use the sudo command.
You can also administer sudo access with such services as Identity Management and LDAP.
2. Enter the visudo command to edit the /etc/sudoers file. This file defines the policies applied by
the sudo command.
121
Red Hat Enterprise Linux 8 Configuring basic system settings
# visudo
3. Find the lines that grant sudo access to users in the group wheel.
4. Make sure the second line does not start with the comment character (#).
6. Add the user to whom you want to grant sudo access to the wheel group:
Verification steps
Test that the updated configuration allows the user to enter commands using sudo.
# su USERNAME -
$ groups
USERNAME wheel
3. Use the sudo command to enter the whoami command. The first time you enter a command
using sudo from a user account, the terminal displays the following banner message. You also
have to enter the password for the user account.
$ sudo whoami
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
4. The last line of the output is the user name returned by the whoami command. If sudo is
configured correctly, this value is root.
When a user tries to use sudo to run a command that is not permitted in the /etc/sudoers file, the
122
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
When a user tries to use sudo to run a command that is not permitted in the /etc/sudoers file, the
system records a message containing username : user NOT in sudoers to the journal log.
The default /etc/sudoers file provides useful information and examples of authorizations. You can
activate a specific example rule by removing the comment character # from the beginning of the line.
The section relevant for user authorizations is marked with the following introduction:
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
You can use the following format to create new sudoers authorizations and to modify existing
authorizations:
username hostname=path/to/command
Where:
username is the name of the relevant user. You can also use the name of a group, for example
%group1.
path/to/command is the complete absolute path to the command. You can also limit the user to
only performing a command with specific options and arguments by adding those options after
the command path. If you do not specify any options, the user can use the command with all
options.
You can replace any of these variables with ALL to apply the rule to all users, hosts, or commands.
CAUTION
Overly permissive rules, such as ALL ALL=(ALL) ALL that permits all users to run all commands as all
users on all hosts, can lead to security risks.
In certain situations, it might be more efficient to specify the arguments negatively using the ! operator.
You can, for example, use !root to specify all users except the root user. Note that using whitelists
(allowing specific users, groups, and commands) is more secure than using blacklists (disallowing specific
users, groups, and commands) because whitelists also block new unauthorized users or groups.
WARNING
Avoid using negative rules for commands because users can overcome such rules by
renaming commands using the alias command.
The system reads the /etc/sudoers file from beginning to end. Therefore, if the file contains multiple
entries for a user, the entries are applied in order. In case of conflicting values, the system uses the last
match, even if it is not the most specific match.
The preferred way of adding new rules to sudoers is by creating new files in the /etc/sudoers.d/
123
Red Hat Enterprise Linux 8 Configuring basic system settings
directory instead of entering rules directly to the /etc/sudoers file. This is because the contents of this
directory are preserved during system updates. In addition, it is easier to fix any errors in the separate
files than in the /etc/sudoers file. The system reads the files in the /etc/sudoers.d directory when it
reaches the following line in the /etc/sudoers file:
#includedir /etc/sudoers.d
Note that the number sign # at the beginning of this line is part of the syntax and does not mean the line
is a comment. The names of files in that directory must not contain a period . and must not end with a
tilde ~.
Prerequisites
Procedure
# mkdir -p /etc/sudoers.d/
# visudo -f /etc/sudoers.d/user1
4. Optional: To receive email notifications every time a user attempts to use sudo, add the
following lines to the file:
Defaults mail_always
Defaults mailto="email@domain.com"
Verification steps
Test that the updated configuration allows user1 to enter the yum command using sudo.
124
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
# su user1 -
2. Enter the yum command with the sudo command, and enter the password for user1.
$ sudo yum
...
usage: yum [options] COMMAND
...
If, however, you receive the following message, the configuration was not completed correctly:
The sudo(8) man page provides an overview of the options available for the sudo command.
The visudo(8) man page describes the editing of the sudoers file.
Use cases:
When you enter su without specifying a user name, and you provide the root password, you
become the root user and have all the related administrative privileges.
Using su - username, you log in to an environment similar to the environment of the target
user, including the HOME directory and the SHELL. To return back to the previous user shell,
close the current shell by entering the exit command or by pressing ctrl+d.
Using su username -c command, you can run a single command as the target user. If you omit
the user name, you can run a command as the root user, similarly to sudo command. In contrast
to sudo, however, you need to enter the root password.
NOTE
SELinux roles do not change with su. You are, therefore, still subject to restrictions
imposed by SELinux, if it is enabled.
125
Red Hat Enterprise Linux 8 Configuring basic system settings
Aspect su sudo
WARNING
Because sudo allows you to set more detailed authorizations and to monitor its use
by other users, sudo is the preferred method for performing tasks with
administrative privileges over su.
Prerequisites
Procedure
1. Open the Pluggable Authentication Module (PAM) configuration file for su, for example, in the
vi text editor:
# vi /etc/pam.d/su
3. Save changes, and exit the file. Only users in the wheel group now have su privileges.
Verification steps
To verify that users in the wheel group have su privileges:
126
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
# su - user1
2. As user1, switch to the root user, and enter the root password:
$ su -
The PAM man page provides details about Pluggable Authentication Modules.
To change the root password after the installation, use the passwd command. With this command, you
can change the root password as the root user and also as a non-root user. For more information, see
Changing the root password as the root user or Changing or resetting forgotten root password as a non-
root user.
To reset forgotten root password, you can also use the passwd command. However, this is only possible
if you are able to log in as a non-root user who belongs to the wheel group. For more information, see
Changing or resetting forgotten root password as a non-root user .
If you are not able to log in as a non-root user belonging to the wheel group, you can reset forgotten
root password during the boot process by switching into the chroot jail environment. For more
information, see Resetting forgotten root password in chroot jail with SELinux in permissive mode or
Resetting forgotten root password in chroot jail with SELinux in enforcing mode .
Prerequisites
You are able to log in as the root user.
To change the root password as the root user, use the following procedure.
Procedure
127
Red Hat Enterprise Linux 8 Configuring basic system settings
Run:
# passwd
Prerequisites
You are able to log in as a non-root user that belongs to the wheel group.
To change the root password as a non-root user who is a member of the wheel group, use the following
procedure.
Procedure
Run:
Updating the password file in chroot jail results in a file with the incorrect SELinux security context.
Therefore, you must relabel all files on the next system boot. However, especially for a large disk, the
relabeling process might be time-consuming. To avoid the relabeling process, you can work with
SELinux switched to permissive mode. For more information, see Resetting forgotten root password in
chroot jail with SELinux in permissive mode.
If you want to work with SELIinux in enforcing mode, use the procedure described in Resetting
forgotten root password in the chroot jail with SELinux in enforcing mode.
4.8.3.1. Resetting forgotten root password in chroot jail with SELinux in permissive mode
Procedure
1. Start the system and, on the GRUB 2 boot screen, press the e key to edit the selected menu
item.
NOTE
Press Ctrl+a and Ctrl+e to jump to the start and end of the line, respectively. On
some systems, Home and End also work.
3. Set SELinux to permissive mode by adding the following at the end of the line starting with
128
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
3. Set SELinux to permissive mode by adding the following at the end of the line starting with
linux:
rd.break enforcing=0
Adding the enforcing=0 option enables omitting the time-consuming SELinux relabeling
process. As a result, the initramfs stops before passing control to the Linux kernel, enabling you
to work with the root file system. Note that the initramfs prompt appears on the last console
specified on the respective line.
NOTE
With an encrypted file system, a password is required at this point. However, the
password prompt might not appear as it is overlaid by logging messages. You can
press the Backspace key to see the prompt. Release the key and enter the
password for the encrypted file system, while ignoring the logging messages.
5. The file system is mounted as read-only on /sysroot/. You cannot change the password if the
file system is not writable. To remount the file system as writable:
sh-4.4# passwd
After entering this command, follow the instructions displayed on the command line to finalize
the change of the root password.
8. Optionally, relabel SELinux security contexts for all files on the next system boot by entering
the following command:
sh-4.4# exit
129
Red Hat Enterprise Linux 8 Configuring basic system settings
switch_root:/# exit
With an encrypted file system, a password or phrase is required at this point. However, the
password prompt might not appear as it is overlaid by logging messages. You can press and hold
the Backspace key to see the prompt. Release the key and enter the password for the
encrypted file system, while ignoring the logging messages.
12. According to whether you relabed SELinux security contexts by using the touch /.autorelabel
as described in the step 8, do the following:
If you relabeled SELinux contexts, wait until the SELinux relabeling process is finished. Note
that the process can take a long time. A system reboots automatically when the process is
complete.
If you omitted the step 8, and you did not relabel SELinux security contexts, follow these
steps:
# restorecon /etc/shadow
# setenforce 1
# getenforce
Enforcing
4.8.3.2. Resetting forgotten root password in chroot jail with SElinux in enforcing mode
Procedure
1. Start the system and, on the GRUB 2 boot screen, press the e key to edit the selected menu
item.
NOTE
Press Ctrl+a and Ctrl+e to jump to the start and end of the line, respectively. On
some systems, Home and End also work.
NOTE
130
CHAPTER 4. MANAGING USER AND GROUP ACCOUNTS
NOTE
With an encrypted file system, a password is required at this point. However, the
password prompt might not appear as it is overlaid by logging messages. You can
press the Backspace key to see the prompt. Release the key and enter the
password for the encrypted file system, while ignoring the logging messages.
4. The file system is mounted as read-only on /sysroot/. You cannot change the password if the
file system is not writable. To remount the file system as writable:
sh-4.4# passwd
Follow the instructions displayed on the command line to finalize the change of the root
password.
7. Updating the password file results in a file with the incorrect SELinux security context. To
relabel all files on the next system boot, enter the following command:
sh-4.4# exit
switch_root:/# exit
With an encrypted file system, a password or phrase is required at this point. However, the
password prompt might not appear as it is overlaid by logging messages. You can press and hold
the Backspace key to see the prompt. Release the key and enter the password for the
encrypted file system, while ignoring the logging messages.
131
Red Hat Enterprise Linux 8 Configuring basic system settings
useradd(8) — The manual page for the useradd command documents how to use it to create
new users.
userdel(8) — The manual page for the userdel command documents how to use it to delete
users.
usermod(8) — The manual page for the usermod command documents how to use it to modify
users.
groupadd(8) — The manual page for the groupadd command documents how to use it to
create new groups.
groupdel(8) — The manual page for the groupdel command documents how to use it to delete
groups.
groupmod(8) — The manual page for the groupmod command documents how to use it to
modify group membership.
gpasswd(1) — The manual page for the gpasswd command documents how to manage the
/etc/group file.
grpck(8) — The manual page for the grpck command documents how to use it to verify the
integrity of the /etc/group file.
pwck(8) — The manual page for the pwck command documents how to use it to verify the
integrity of the /etc/passwd and /etc/shadow files.
pwconv(8) — The manual page for the pwconv, pwunconv, grpconv, and grpunconv
commands documents how to convert shadowed information for passwords and groups.
id(1) — The manual page for the id command documents how to display user and group IDs.
group(5) — The manual page for the /etc/group file documents how to use this file to define
system groups.
passwd(5) — The manual page for the /etc/passwd file documents how to use this file to
define user information.
shadow(5) — The manual page for the /etc/shadow file documents how to use this file to set
passwords and account expiration information for the system.
132
CHAPTER 5. MANAGING FILE PERMISSIONS
3 = for group permissions, the execute and write bits are set
7 = for others permissions, the execute, write, and read bits are set
Umasks can be represented in binary, octal, or symbolic notation. For example, the octal representation
0137 equals symbolic representation u=rw-,g=r--,o=---. Symbolic notation specification is the reverse of
the octal notation specification: it shows the allowed permissions, not the prohibited permissions.
When a bit is not set in umask, it can be set in the file, depending on other factors.
The following figure shows how umask 0137 affects creating a new file.
IMPORTANT
For security reasons, a regular file cannot have execute permissions by default. Therefore,
even if umask is 0000, which does not prohibit any permissions, a new regular file still does
not have execute permissions. However, directories can be created with execute
permissions:
Procedure
$ umask
0022
134
CHAPTER 5. MANAGING FILE PERMISSIONS
Procedure
$ umask -S
u=rwx,g=rx,o=rx
To set umask for the current shell session using octal notation, use this procedure.
Procedure
$ umask octal_mask
Substitute octal_mask with four or less digits from 0 to 7. When three or less digits are provided,
permissions are set as if the command contained leading zeros. For example, umask 7 translates to 0007.
To prohibit new files from having write and execute permissions for owner and group, and from
having any permissions for others:
$ umask 0337
Or:
$ umask 337
To set umask for the current shell session using symbolic notation, use this procedure.
Procedure
$ umask -S symbolic_mask
$ umask -S u=r,g=r,o=
135
Red Hat Enterprise Linux 8 Configuring basic system settings
Shells usually have a configuration file where their default umask is set. For bash, the default
configuration file is /etc/bashrc.
This section describes how to display and change the default bash umask, and how to do this for a
specific user.
Procedure
The output shows if umask is set, either using the umask command or the UMASK variable. In
this example, umask is set to 022 using the umask command:
Procedure
Change the umask command call or the UMASK variable assignment in /etc/bashrc to the
required value of umask. This example changes the default umask to 0227:
By default, bash umask of a new user defaults to the one defined in /etc/bashrc.
Procedure
Add a call to the umask command in $HOME/.bashrc file of that user. For example, to change
bash umask of user john to 0227:
136
CHAPTER 5. MANAGING FILE PERMISSIONS
To change permissions with which user home directories are created, use this procedure.
Procedure
137
Red Hat Enterprise Linux 8 Configuring basic system settings
The user space daemon updates the system clock running in the kernel. The system clock can keep time
by using various clock sources. Usually, the Time Stamp Counter (TSC) is used. The TSC is a CPU
register which counts the number of cycles since it was last reset. It is very fast, has a high resolution,
and there are no interruptions.
In Red Hat Enterprise Linux 8, the NTP protocol is implemented by the chronyd daemon, available from
the repositories in the chrony package.
To synchronize the system clock with a reference clock, for example a GPS receiver
As an NTPv4(RFC 5905) server or peer to provide a time service to other computers in the
network
chrony performs well in a wide range of conditions, including intermittent network connections, heavily
congested networks, changing temperatures (ordinary computer clocks are sensitive to temperature),
and systems that do not run continuously, or run on a virtual machine.
Typical accuracy between two machines synchronized over the Internet is within a few milliseconds, and
for machines on a LAN within tens of microseconds. Hardware timestamping or a hardware reference
clock may improve accuracy between two machines synchronized to a sub-microsecond level.
chrony consists of chronyd, a daemon that runs in user space, and chronyc, a command line program
which can be used to monitor the performance of chronyd and to change various operating parameters
when it is running.
The chrony daemon, chronyd, can be monitored and controlled by the command line utility chronyc.
This utility provides a command prompt which allows entering a number of commands to query the
current state of chronyd and make changes to its configuration. By default, chronyd accepts only
commands from a local instance of chronyc, but it can be configured to accept monitoring commands
also from remote hosts. The remote access should be restricted.
# chronyc
138
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
chronyc must run as root if some of the restricted commands are to be used.
chronyc>
The utility can also be invoked in non-interactive command mode if called together with a command as
follows:
chronyc command
NOTE
Changes made using chronyc are not permanent, they will be lost after a chronyd
restart. For permanent changes, modify /etc/chrony.conf.
Both ntp and chrony can operate as an NTP client in order to synchronize the system clock with NTP
servers and they can operate as an NTP server for other computers in the network. Each implementation
has some unique features. For comparison of ntp and chrony, see Comparison of NTP
implementations.
Configuration specific to an NTP client is identical in most cases. NTP servers are specified with the
server directive. A pool of servers can be specified with the pool directive.
Configuration specific to an NTP server differs in how the client access is controlled. By default, ntpd
responds to client requests from any address. The access can be restricted with the restrict directive,
but it is not possible to disable the access completely if ntpd uses any servers as a client. chronyd
allows no access by default and operates as an NTP client only. To make chrony operate as an NTP
server, you need to specify some addresses within the allow directive.
ntpd and chronyd differ also in the default behavior with respect to corrections of the system clock.
ntpd corrects the clock by step when the offset is larger than 128 milliseconds. If the offset is larger than
1000 seconds, ntpd exits unless it is the first correction of the clock and ntpd is started with the -g
option. chronyd does not step the clock by default, but the default chrony.conf file provided in the
chrony package allows steps in the first three updates of the clock. After that, all corrections are made
slowly by speeding up or slowing down the clock. The chronyc makestep command can be issued to
force chronyd to step the clock at any time.
In Red Hat Enterprise Linux 8, ntp is no longer supported. chrony is enabled by default. For this reason,
you might need to migrate from ntp to chrony.
139
Red Hat Enterprise Linux 8 Configuring basic system settings
Migrating from ntp to chrony is straightforward in most cases. The corresponding names of the
programs, configuration files and services are:
Table 6.1. Corresponding names of the programs, configuration files and services when migrating
from ntp to chrony
/etc/ntp.conf /etc/chrony.conf
/etc/ntp/keys /etc/chrony.keys
ntpd chronyd
ntpq chronyc
ntpd.service chronyd.service
ntp-wait.service chrony-wait.service
The ntpdate and sntp utilities, which are included in the ntp distribution, can be replaced with chronyd
using the -q option or the -t option. The configuration can be specified on the command line to avoid
reading /etc/chrony.conf. For example, instead of running ntpdate ntp.example.com, chronyd could
be started as:
The ntpstat utility, which was previously included in the ntp package and supported only ntpd, now
supports both ntpd and chronyd. It is available in the ntpstat package.
By default, the script does not overwrite any files. If /etc/chrony.conf or /etc/chrony.keys already exist,
the -b option can be used to rename the file as a backup. The script supports other options. The --help
option prints all supported options.
An example of an invocation of the script with the default ntp.conf provided in the ntp package is:
# python3 /usr/share/doc/chrony/ntp2chrony.py -b -v
Reading /etc/ntp.conf
140
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
Reading /etc/ntp/crypto/pw
Reading /etc/ntp/keys
Writing /etc/chrony.conf
Writing /etc/chrony.keys
The only directive ignored in this case is disable monitor, which has a chrony equivalent in the
noclientlog directive, but it was included in the default ntp.conf only to mitigate an amplification attack.
The generated chrony.conf file typically includes a number of allow directives corresponding to the
restrict lines in ntp.conf. If you do not want to run chronyd as an NTP server, remove all allow directives
from chrony.conf.
For more information on using the timesync role to manage time synchronization, see System roles
documentation.
Comments
Comments should be preceded by #, %, ; or !
allow
Optionally specify a host, subnet, or network from which to allow NTP connections to a machine
acting as NTP server. The default is not to allow connections.
Examples:
allow 192.0.2.0/24
allow 2001:0db8:85a3::8a2e:0370:7334
The UDP port number 123 needs to be open in the firewall in order to allow the client access:
If you want to open port 123 permanently, use the --permanent option:
141
Red Hat Enterprise Linux 8 Configuring basic system settings
cmdallow
This is similar to the allow directive (see section allow), except that it allows control access (rather
than NTP client access) to a particular subnet or host. (By "control access" is meant that chronyc
can be run on those hosts and successfully connect to chronyd on this computer.) The syntax is
identical. There is also a cmddeny all directive with similar behavior to the cmdallow all directive.
dumpdir
Path to the directory to save the measurement history across restarts of chronyd (assuming no
changes are made to the system clock behavior whilst it is not running). If this capability is to be used
(via the dumponexit command in the configuration file, or the dump command in chronyc), the
dumpdir command should be used to define the directory where the measurement histories are
saved.
dumponexit
If this command is present, it indicates that chronyd should save the measurement history for each
of its time sources recorded whenever the program exits. (See the dumpdir command above).
hwtimestamp
The hwtimestamp directive enables hardware timestamping for extremely accurate synchronization.
For more details, see the chrony.conf(5) manual page.
local
The local keyword is used to allow chronyd to appear synchronized to real time from the viewpoint
of clients polling it, even if it has no current synchronization source. This option is normally used on
the "master" computer in an isolated network, where several computers are required to synchronize
to one another, and the "master" is kept in line with real time by manual input.
An example of the command is:
local stratum 10
A large value of 10 indicates that the clock is so many hops away from a reference clock that its time
is unreliable. If the computer ever has access to another computer which is ultimately synchronized to
a reference clock, it will almost certainly be at a stratum less than 10. Therefore, the choice of a high
value like 10 for the local command prevents the machine’s own time from ever being confused with
real time, were it ever to leak out to clients that have visibility of real servers.
log
The log command indicates that certain information is to be logged. It accepts the following options:
measurements
This option logs the raw NTP measurements and related information to a file called
measurements.log.
statistics
This option logs information about the regression processing to a file called statistics.log.
tracking
This option logs changes to the estimate of the system’s gain or loss rate, and any slews made, to
a file called tracking.log.
rtc
This option logs information about the system’s real-time clock.
refclocks
This option logs the raw and filtered reference clock measurements to a file called refclocks.log.
tempcomp
This option logs the temperature measurements and system rate compensations to a file called
142
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
This option logs the temperature measurements and system rate compensations to a file called
tempcomp.log.
The log files are written to the directory specified by the logdir command.
logdir
This directive allows the directory where log files are written to be specified.
An example of the use of this directive is:
logdir /var/log/chrony
makestep
Normally chronyd will cause the system to gradually correct any time offset, by slowing down or
speeding up the clock as required. In certain situations, the system clock may be so far adrift that this
slewing process would take a very long time to correct the system clock. This directive forces
chronyd to step system clock if the adjustment is larger than a threshold value, but only if there were
no more clock updates since chronyd was started than a specified limit (a negative value can be used
to disable the limit). This is particularly useful when using reference clock, because the initstepslew
directive only works with NTP sources.
An example of the use of this directive is:
makestep 1000 10
This would step the system clock if the adjustment is larger than 1000 seconds, but only in the first
ten clock updates.
maxchange
This directive sets the maximum allowed offset corrected on a clock update. The check is performed
only after the specified number of updates to allow a large initial adjustment of the system clock.
When an offset larger than the specified maximum occurs, it will be ignored for the specified number
of times and then chronyd will give up and exit (a negative value can be used to never exit). In both
cases a message is sent to syslog.
An example of the use of this directive is:
maxchange 1000 1 2
After the first clock update, chronyd will check the offset on every clock update, it will ignore two
adjustments larger than 1000 seconds and exit on another one.
maxupdateskew
One of chronyd's tasks is to work out how fast or slow the computer’s clock runs relative to its
reference sources. In addition, it computes an estimate of the error bounds around the estimated
value.
If the range of error is too large, it indicates that the measurements have not settled down yet, and
that the estimated gain or loss rate is not very reliable.
The maxupdateskew parameter is the threshold for determining whether an estimate is too
unreliable to be used. By default, the threshold is 1000 ppm.
143
Red Hat Enterprise Linux 8 Configuring basic system settings
maxupdateskew skew-in-ppm
Typical values for skew-in-ppm might be 100 for a dial-up connection to servers over a telephone
line, and 5 or 10 for a computer on a LAN.
It should be noted that this is not the only means of protection against using unreliable estimates. At
all times, chronyd keeps track of both the estimated gain or loss rate, and the error bound on the
estimate. When a new estimate is generated following another measurement from one of the
sources, a weighted combination algorithm is used to update the master estimate. So if chronyd has
an existing highly-reliable master estimate and a new estimate is generated which has large error
bounds, the existing master estimate will dominate in the new master estimate.
minsources
The minsources directive sets the minimum number of sources that need to be considered as
selectable in the source selection algorithm before the local clock is updated.
The format of the syntax is:
minsources number-of-sources
By default, number-of-sources is 1. Setting minsources to a larger number can be used to improve the
reliability, because multiple sources will need to correspond with each other.
noclientlog
This directive, which takes no arguments, specifies that client accesses are not to be logged.
Normally they are logged, allowing statistics to be reported using the clients command in chronyc
and enabling the clients to use interleaved mode with the xleave option in the server directive.
reselectdist
When chronyd selects synchronization source from available sources, it will prefer the one with
minimum synchronization distance. However, to avoid frequent reselecting when there are sources
with similar distance, a fixed distance is added to the distance for sources that are currently not
selected. This can be set with the reselectdist option. By default, the distance is 100 microseconds.
The format of the syntax is:
reselectdist dist-in-seconds
stratumweight
The stratumweight directive sets how much distance should be added per stratum to the
synchronization distance when chronyd selects the synchronization source from available sources.
The format of the syntax is:
stratumweight dist-in-seconds
By default, dist-in-seconds is 1 millisecond. This means that sources with lower stratum are usually
preferred to sources with higher stratum even when their distance is significantly worse. Setting
stratumweight to 0 makes chronyd ignore stratum when selecting the source.
rtcfile
The rtcfile directive defines the name of the file in which chronyd can save parameters associated
with tracking the accuracy of the system’s real-time clock (RTC).
144
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
rtcfile /var/lib/chrony/rtc
chronyd saves information in this file when it exits and when the writertc command is issued in
chronyc. The information saved is the RTC’s error at some epoch, that epoch (in seconds since
January 1 1970), and the rate at which the RTC gains or loses time. Not all real-time clocks are
supported as their code is system-specific. Note that if this directive is used then the real-time clock
should not be manually adjusted as this would interfere with chrony's need to measure the rate at
which the real-time clock drifts if it was adjusted at random intervals.
rtcsync
The rtcsync directive is present in the /etc/chrony.conf file by default. This will inform the kernel the
system clock is kept synchronized and the kernel will update the real-time clock every 11 minutes.
Unix domain socket, which is accessible locally by the root or chrony user.
By default, chronyc connects to the Unix domain socket. The default path is
/var/run/chrony/chronyd.sock. If this connection fails, which can happen for example when chronyc is
running under a non-root user, chronyc tries to connect to 127.0.0.1 and then ::1.
Only the following monitoring commands, which do not affect the behavior of chronyd, are allowed from
the network:
activity
manual list
rtcdata
smoothing
sources
sourcestats
tracking
waitsync
The set of hosts from which chronyd accepts these commands can be configured with the cmdallow
directive in the configuration file of chronyd, or the cmdallow command in chronyc. By default, the
commands are accepted only from localhost (127.0.0.1 or ::1).
All other commands are allowed only through the Unix domain socket. When sent over the network,
chronyd responds with a Not authorised error, even if it is from localhost.
1. Allow access from both IPv4 and IPv6 addresses by adding the following to the
145
Red Hat Enterprise Linux 8 Configuring basic system settings
1. Allow access from both IPv4 and IPv6 addresses by adding the following to the
/etc/chrony.conf file:
bindcmdaddress 0.0.0.0
or
bindcmdaddress :
2. Allow commands from the remote IP address, network, or subnet by using the cmdallow
directive.
Add the following content to the /etc/chrony.conf file:
cmdallow 192.168.1.0/24
Note that the allow directive is for NTP access whereas the cmdallow directive is to enable receiving of
remote commands. It is possible to make these changes temporarily using chronyc running locally. Edit
the configuration file to make permanent changes.
The default location for the chrony daemon is /usr/sbin/chronyd. The command line utility will be
installed to /usr/bin/chronyc.
146
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
To ensure chronyd starts automatically at system start, issue the following command as root:
To prevent chronyd from starting automatically at system start, issue the following command as root:
$ chronyc tracking
Reference ID : CB00710F (foo.example.net)
Stratum :3
Ref time (UTC) : Fri Jan 27 09:49:17 2017
System time : 0.000006523 seconds slow of NTP time
Last offset : -0.000006747 seconds
RMS offset : 0.000035822 seconds
Frequency : 3.225 ppm slow
Residual freq : 0.000 ppm
Skew : 0.129 ppm
Root delay : 0.013639022 seconds
Root dispersion : 0.001100737 seconds
Update interval : 64.2 seconds
Leap status : Normal
Reference ID
This is the reference ID and name (or IP address) if available, of the server to which the computer is
currently synchronized. Reference ID is a hexadecimal number to avoid confusion with IPv4
addresses.
Stratum
The stratum indicates how many hops away from a computer with an attached reference clock we
are. Such a computer is a stratum-1 computer, so the computer in the example is two hops away (that
is to say, a.b.c is a stratum-2 and is synchronized from a stratum-1).
Ref time
This is the time (UTC) at which the last measurement from the reference source was processed.
147
Red Hat Enterprise Linux 8 Configuring basic system settings
System time
In normal operation, chronyd never steps the system clock, because any jump in the timescale can
have adverse consequences for certain application programs. Instead, any error in the system clock is
corrected by slightly speeding up or slowing down the system clock until the error has been removed,
and then returning to the system clock’s normal speed. A consequence of this is that there will be a
period when the system clock (as read by other programs using the gettimeofday() system call, or by
the date command in the shell) will be different from chronyd's estimate of the current true time
(which it reports to NTP clients when it is operating in server mode). The value reported on this line is
the difference due to this effect.
Last offset
This is the estimated local offset on the last clock update.
RMS offset
This is a long-term average of the offset value.
Frequency
The "frequency" is the rate by which the system’s clock would be wrong if chronyd was not
correcting it. It is expressed in ppm (parts per million). For example, a value of 1 ppm would mean that
when the system’s clock thinks it has advanced 1 second, it has actually advanced by 1.000001
seconds relative to true time.
Residual freq
This shows the "residual frequency" for the currently selected reference source. This reflects any
difference between what the measurements from the reference source indicate the frequency
should be and the frequency currently being used.
The reason this is not always zero is that a smoothing procedure is applied to the frequency. Each
time a measurement from the reference source is obtained and a new residual frequency computed,
the estimated accuracy of this residual is compared with the estimated accuracy (see skew) of the
existing frequency value. A weighted average is computed for the new frequency, with weights
depending on these accuracies. If the measurements from the reference source follow a consistent
trend, the residual will be driven to zero over time.
Skew
This is the estimated error bound on the frequency.
Root delay
This is the total of the network path delays to the stratum-1 computer from which the computer is
ultimately synchronized. Root delay values are printed in nanosecond resolution. In certain extreme
situations, this value can be negative. (This can arise in a symmetric peer arrangement where the
computers’ frequencies are not tracking each other and the network delay is very short relative to the
turn-around time at each computer.)
Root dispersion
This is the total dispersion accumulated through all the computers back to the stratum-1 computer
from which the computer is ultimately synchronized. Dispersion is due to system clock resolution,
statistical measurement variations etc. Root dispersion values are printed in nanosecond resolution.
Leap status
This is the leap status, which can be Normal, Insert second, Delete second or Not synchronized.
The sources command displays information about the current time sources that chronyd is accessing.
The optional argument -v can be specified, meaning verbose. In this case, extra caption lines are shown
as a reminder of the meanings of the columns.
148
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
$ chronyc sources
210 Number of sources = 3
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
M
This indicates the mode of the source. ^ means a server, = means a peer and # indicates a locally
connected reference clock.
S
This column indicates the state of the sources. "*" indicates the source to which chronyd is currently
synchronized. "+" indicates acceptable sources which are combined with the selected source. "-"
indicates acceptable sources which are excluded by the combining algorithm. "?" indicates sources to
which connectivity has been lost or whose packets do not pass all tests. "x" indicates a clock which
chronyd thinks is a falseticker (its time is inconsistent with a majority of other sources). "~" indicates
a source whose time appears to have too much variability. The "?" condition is also shown at start-
up, until at least 3 samples have been gathered from it.
Name/IP address
This shows the name or the IP address of the source, or reference ID for reference clock.
Stratum
This shows the stratum of the source, as reported in its most recently received sample. Stratum 1
indicates a computer with a locally attached reference clock. A computer that is synchronized to a
stratum 1 computer is at stratum 2. A computer that is synchronized to a stratum 2 computer is at
stratum 3, and so on.
Poll
This shows the rate at which the source is being polled, as a base-2 logarithm of the interval in
seconds. Thus, a value of 6 would indicate that a measurement is being made every 64 seconds.
chronyd automatically varies the polling rate in response to prevailing conditions.
Reach
This shows the source’s reach register printed as an octal number. The register has 8 bits and is
updated on every received or missed packet from the source. A value of 377 indicates that a valid
reply was received for all of the last eight transmissions.
LastRx
This column shows how long ago the last sample was received from the source. This is normally in
seconds. The letters m, h, d or y indicate minutes, hours, days or years. A value of 10 years indicates
there were no samples received from this source yet.
Last sample
This column shows the offset between the local clock and the source at the last measurement. The
number in the square brackets shows the actual measured offset. This may be suffixed by ns
(indicating nanoseconds), us (indicating microseconds), ms (indicating milliseconds), or s
(indicating seconds). The number to the left of the square brackets shows the original measurement,
adjusted to allow for any slews applied to the local clock since. The number following the +/- indicator
shows the margin of error in the measurement. Positive offsets indicate that the local clock is ahead
of the source.
149
Red Hat Enterprise Linux 8 Configuring basic system settings
The sourcestats command displays information about the drift rate and offset estimation process for
each of the sources currently being examined by chronyd.
The optional argument -v can be specified, meaning verbose. In this case, extra caption lines are shown
as a reminder of the meanings of the columns.
$ chronyc sourcestats
210 Number of sources = 1
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
===============================================================================
Name/IP address
This is the name or IP address of the NTP server (or peer) or reference ID of the reference clock to
which the rest of the line relates.
NP
This is the number of sample points currently being retained for the server. The drift rate and current
offset are estimated by performing a linear regression through these points.
NR
This is the number of runs of residuals having the same sign following the last regression. If this
number starts to become too small relative to the number of samples, it indicates that a straight line
is no longer a good fit to the data. If the number of runs is too low, chronyd discards older samples
and re-runs the regression until the number of runs becomes acceptable.
Span
This is the interval between the oldest and newest samples. If no unit is shown the value is in seconds.
In the example, the interval is 46 minutes.
Frequency
This is the estimated residual frequency for the server, in parts per million. In this case, the
computer’s clock is estimated to be running 1 part in 109 slow relative to the server.
Freq Skew
This is the estimated error bounds on Freq (again in parts per million).
Offset
This is the estimated offset of the source.
Std Dev
This is the estimated sample standard deviation.
# chronyc makestep
If the rtcfile directive is used, the real-time clock should not be manually adjusted. Random adjustments
would interfere with chrony's need to measure the rate at which the real-time clock drifts.
150
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
On the system selected to be the master, using a text editor running as root, edit /etc/chrony.conf as
follows:
driftfile /var/lib/chrony/drift
commandkey 1
keyfile /etc/chrony.keys
initstepslew 10 client1 client3 client6
local stratum 8
manual
allow 192.0.2.0
Where 192.0.2.0 is the network or subnet address from which the clients are allowed to connect.
On the systems selected to be direct clients of the master, using a text editor running as root, edit the
/etc/chrony.conf as follows:
server master
driftfile /var/lib/chrony/drift
logdir /var/log/chrony
log measurements statistics tracking
keyfile /etc/chrony.keys
commandkey 24
local stratum 10
initstepslew 20 master
allow 192.0.2.123
Where 192.0.2.123 is the address of the master, and master is the host name of the master. Clients with
this configuration will resynchronize the master if it restarts.
On the client systems which are not to be direct clients of the master, the /etc/chrony.conf file should
be the same except that the local and allow directives should be omitted.
In an isolated network, you can also use the local directive that enables a local reference mode, which
allows chronyd operating as an NTP server to appear synchronized to real time, even when it was never
synchronized or the last update of the clock happened a long time ago.
To allow multiple servers in the network to use the same local configuration and to be synchronized to
one another, without confusing clients that poll more than one server, use the orphan option of the
local directive which enables the orphan mode. Each server needs to be configured to poll all other
servers with local. This ensures that only the server with the smallest reference ID has the local
reference active and other servers are synchronized to it. When the server fails, another one will take
over.
151
Red Hat Enterprise Linux 8 Configuring basic system settings
Another protocol for time synchronization that uses hardware timestamping is PTP.
Unlike NTP, PTP relies on assistance in network switches and routers. If you want to reach the best
accuracy of synchronization, use PTP on networks that have switches and routers with PTP support, and
prefer NTP on networks that do not have such switches and routers.
# ethtool -T eth0
Output:
152
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
ptpv2-event (HWTSTAMP_FILTER_PTP_V2_EVENT)
ptpv2-sync (HWTSTAMP_FILTER_PTP_V2_SYNC)
ptpv2-delay-req (HWTSTAMP_FILTER_PTP_V2_DELAY_REQ)
hwtimestamp eth0
hwtimestamp eth1
hwtimestamp *
The following directive in /etc/chrony.conf specifies a local NTP server using one second polling
interval:
clientloglimit 100000000
153
Red Hat Enterprise Linux 8 Configuring basic system settings
Example 6.3. Log messages for interfaces with enabled hardware timestamping
When chronyd is configured as an NTP client or peer, you can have the transmit and receive
timestamping modes and the interleaved mode reported for each NTP source by the chronyc ntpdata
command:
Example 6.4. Reporting the transmit, receive timestamping and interleaved mode for each NTP
source
# chronyc ntpdata
Output:
154
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
# chronyc sourcestats
With hardware timestamping enabled, stability of NTP measurements should be in tens or hundreds
of nanoseconds, under normal load. This stability is reported in the Std Dev column of the output of
the chronyc sourcestats command:
Output:
Configure the ptp4l and phc2sys programs from the linuxptp packages to use one interface to
synchronize the system clock using PTP.
Configure chronyd to provide the system time using the other interface:
Example 6.6. Configuring chronyd to provide the system time using the other interface
bindaddress 203.0.113.74
hwtimestamp eth1
local stratum 1
To monitor the status of the system clock sychronized by chronyd, you can:
Use the ntpstat utility, which supports chrony and provides a similar output as it used to with
ntpd
155
Red Hat Enterprise Linux 8 Configuring basic system settings
$ chronyc -n tracking
Reference ID : 0A051B0A (10.5.27.10)
Stratum :2
Ref time (UTC) : Thu Mar 08 15:46:20 2018
System time : 0.000000338 seconds slow of NTP time
Last offset : +0.000339408 seconds
RMS offset : 0.000339408 seconds
Frequency : 2.968 ppm slow
Residual freq : +0.001 ppm
Skew : 3.336 ppm
Root delay : 0.157559142 seconds
Root dispersion : 0.001339232 seconds
Update interval : 64.5 seconds
Leap status : Normal
$ ntpstat
synchronised to NTP server (10.5.27.10) at stratum 2
time correct to within 80 ms
polling server every 64 s
On a Red Hat Enterprise Linux 8 system, it is recommended to use symmetric keys instead. Generate
the keys with the chronyc keygen command. A client and server need to share a key specified in
/etc/chrony.keys. The client can enable authentication using the key option in the server, pool, or peer
directive.
Note that using the client/server mode enabled by the server or pool directive is more secure
compared to the symmetric mode enabled by the peer directive.
In Red Hat Enterprise Linux 8, chronyd does not support the broadcast/multicast mode. The main
156
CHAPTER 6. USING THE CHRONY SUITE TO CONFIGURE NTP
In Red Hat Enterprise Linux 8, chronyd does not support the broadcast/multicast mode. The main
reason is that it is less accurate and less secure than the ordinary client/server and symmetric modes.
PTP was designed for multicast messaging and works similarly to the NTP broadcast mode. A
PTP implementation is available in the linuxptp package.
PTP normally requires hardware timestamping and support in network switches to perform well.
However, PTP is expected to work better than NTP in the broadcast mode even with software
timestamping and no support in network switches.
In networks with very large number of PTP slaves in one communication path, it is recommended
to configure the PTP slaves with the hybrid_e2e option in order to reduce the amount of
network traffic generated by the slaves. You can configure a computer running chronyd as an
NTP client, and possibly NTP server, to operate also as a PTP grandmaster to distribute
synchronized time to a large number of computers using multicast messaging.
chronyd(8) man page — Describes the chronyd daemon including commands and command
options.
https://chrony.tuxfamily.org/doc/3.3/chronyd.html
https://chrony.tuxfamily.org/doc/3.3/chrony.conf.html
157
Red Hat Enterprise Linux 8 Configuring basic system settings
The timesync role installs and configures an NTP or PTP implementation to operate as an NTP client or
PTP slave in order to synchronize the system clock with NTP servers or grandmasters in PTP domains.
Note that using the timesync role also facilitates migration to chrony , because you can use the same
playbook on all versions of Red Hat Enterprise Linux starting with RHEL 6 regardless of whether the
system uses ntp or chrony to implement the NTP protocol.
WARNING
The timesync role replaces the configuration of the given or detected provider
service on the managed host. Previous settings are lost, even if they are not
specified in the role variables. The only preserved setting is the choice of provider if
the timesync_ntp_provider variable is not defined.
The following example shows how to apply the timesync role in a situation with just one pool of servers.
Example 6.9. An example playbook applying the timesync role for a single pool of servers
---
- hosts: timesync-test
vars:
timesync_ntp_servers:
- hostname: 2.rhel.pool.ntp.org
pool: yes
iburst: yes
roles:
- rhel-system-roles.timesync
For more information on using the timesync role, see System roles documentation .
158
CHAPTER 7. USING SECURE COMMUNICATIONS BETWEEN TWO SYSTEMS WITH OPENSSH
Red Hat Enterprise Linux includes the basic OpenSSH packages: the general openssh package, the
openssh-server package and the openssh-clients package. Note that the OpenSSH packages require
the OpenSSL package openssl-libs, which installs several important cryptographic libraries that enable
OpenSSH to provide encrypted communications.
The SSH protocol mitigates security threats, such as interception of communication between two
systems and impersonation of a particular host, when you use it for remote shell login or file copying.
This is because the SSH client and server use digital signatures to verify their identities. Additionally, all
communication between the client and server systems is encrypted.
OpenSSH is an implementation of the SSH protocol supported by a number of Linux, UNIX, and similar
operating systems. It includes the core files necessary for both the OpenSSH client and server. The
OpenSSH suite consists of the following user-space tools:
ssh-copy-id is a script that adds local public keys to the authorized_keys file on a remote SSH
server
Two versions of SSH currently exist: version 1, and the newer version 2. The OpenSSH suite in Red Hat
Enterprise Linux 8 supports only SSH version 2, which has an enhanced key-exchange algorithm not
vulnerable to known exploits in version 1.
OpenSSH, as one of the RHEL core cryptographic subsystems uses system-wide crypto policies. This
ensures that weak cipher suites and cryptographic algorithms are disabled in the default configuration.
To adjust the policy, the administrator must either use the update-crypto-policies command to make
settings stricter or looser or manually opt-out of the system-wide crypto policies.
159
Red Hat Enterprise Linux 8 Configuring basic system settings
The OpenSSH suite uses two different sets of configuration files: those for client programs (that is, ssh,
scp, and sftp), and those for the server (the sshd daemon). System-wide SSH configuration
information is stored in the /etc/ssh/ directory. User-specific SSH configuration information is stored in
~/.ssh/ in the user’s home directory. For a detailed list of OpenSSH configuration files, see the FILES
section in the sshd(8) man page.
Additional resources
Man pages for the ssh topic listed by the man -k ssh command.
Prerequisites
Procedure
1. Start the sshd daemon in the current session and set it to start automatically at boot time:
2. To specify different addresses than the default 0.0.0.0 (IPv4) or :: (IPv6) for the
ListenAddress directive in the /etc/ssh/sshd_config configuration file and to use a slower
dynamic network configuration, add the dependency on the network-online.target target unit
to the sshd.service unit file. To achieve this, create the
/etc/systemd/system/sshd.service.d/local.conf file with the following content:
[Unit]
Wants=network-online.target
After=network-online.target
3. Review if OpenSSH server settings in the /etc/ssh/sshd_config configuration file meet the
requirements of your scenario.
4. Optionally, change the welcome message that your OpenSSH server displays before a client
authenticates by editing the /etc/issue file, for example:
Welcome to ssh-server.example.com
Warning: By accessing this server, you agree to the referenced terms and conditions.
Note that to change the message displayed after a successful login you have to edit the
/etc/motd file on the server. See the pam_motd man page for more information.
# systemctl daemon-reload
160
CHAPTER 7. USING SECURE COMMUNICATIONS BETWEEN TWO SYSTEMS WITH OPENSSH
Verification steps
# ssh user@ssh-server-example.com
ECDSA key fingerprint is SHA256:dXbaS0RG/UzlTTku8GtXSz0S1++lPegSy31v3L/FAEc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ssh-server-example.com' (ECDSA) to the list of known hosts.
user@ssh-server-example.com's password:
Additional resources
Prerequisites
Procedure
161
Red Hat Enterprise Linux 8 Configuring basic system settings
# vi /etc/ssh/sshd_config
PasswordAuthentication no
On a system other than a new default installation, check that PubkeyAuthentication no has not
been set and the ChallengeResponseAuthentication directive is set to no. If you are
connected remotely, not using console or out-of-band access, test the key-based login process
before disabling password authentication.
# setsebool -P use_nfs_home_dirs 1
Additional resources
IMPORTANT
If you complete the following steps as root, only root is able to use the keys.
Procedure
$ ssh-keygen -t ecdsa
Generating public/private ecdsa key pair.
Enter file in which to save the key (/home/joesec/.ssh/id_ecdsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/joesec/.ssh/id_ecdsa.
Your public key has been saved in /home/joesec/.ssh/id_ecdsa.pub.
The key fingerprint is:
SHA256:Q/x+qms4j7PCQ0qFd09iZEFHA+SqwBKRNaU72oZfaCI
joesec@localhost.example.com
The key's randomart image is:
+---[ECDSA 256]---+
|.oo..o=++ |
|.. o .oo . |
|. .. o. o |
162
CHAPTER 7. USING SECURE COMMUNICATIONS BETWEEN TWO SYSTEMS WITH OPENSSH
|....o.+... |
|o.oo.o +S . |
|.=.+. .o |
|E.*+. . . . |
|.=..+ +.. o |
| . oo*+o. |
+----[SHA256]-----+
You can also generate an RSA key pair by using the -t rsa option with the ssh-keygen
command or an Ed25519 key pair by entering the ssh-keygen -t ed25519 command.
$ ssh-copy-id joesec@ssh-server-example.com
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are
already installed
...
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'joesec@ssh-server-example.com'" and check to
make sure that only the key(s) you wanted were added.
If you do not use the ssh-agent program in your session, the previous command copies the
most recently modified ~/.ssh/id*.pub public key if it is not yet installed. To specify another
public-key file or to prioritize keys in files over keys cached in memory by ssh-agent, use the
ssh-copy-id command with the -i option.
NOTE
If you reinstall your system and want to keep previously generated key pairs, back up the
~/.ssh/ directory. After reinstalling, copy it back to your home directory. You can do this
for all users on your system, including root.
Verification steps
$ ssh joesec@ssh-server-example.com
Welcome message.
...
Last login: Mon Nov 18 18:28:42 2019 from ::1
Additional resources
Prerequisites
163
Red Hat Enterprise Linux 8 Configuring basic system settings
On the client side, the opensc package is installed and the pcscd service is running.
Procedure
1. List all keys provided by the OpenSC PKCS #11 module including their PKCS #11 URIs and save
the output to the keys.pub file:
2. To enable authentication using a smart card on a remote server (example.com), transfer the
public key to the remote server. Use the ssh-copy-id command with keys.pub created in the
previous step:
3. To connect to example.com using the ECDSA key from the output of the ssh-keygen -D
command in step 1, you can use just a subset of the URI, which uniquely references your key, for
example:
4. You can use the same URI string in the ~/.ssh/config file to make the configuration permanent:
$ cat ~/.ssh/config
IdentityFile "pkcs11:id=%01?module-path=/usr/lib64/pkcs11/opensc-pkcs11.so"
$ ssh example.com
Enter PIN for 'SSH key':
[example.com] $
Because OpenSSH uses the p11-kit-proxy wrapper and the OpenSC PKCS #11 module is
registered to PKCS#11 Kit, you can simplify the previous commands:
If you skip the id= part of a PKCS #11 URI, OpenSSH loads all keys that are available in the proxy module.
This can reduce the amount of typing required:
Additional resources
164
CHAPTER 7. USING SECURE COMMUNICATIONS BETWEEN TWO SYSTEMS WITH OPENSSH
IMPORTANT
To make SSH truly effective, prevent the use of insecure connection protocols that are replaced
by the OpenSSH suite. Otherwise, a user’s password might be protected using SSH for one
session only to be captured later when logging in using Telnet. For this reason, consider
disabling insecure protocols, such as telnet, rsh, rlogin, and ftp.
Disabling passwords for authentication and allowing only key pairs reduces the attack surface
and it also might save users’ time. On clients, generate key pairs using the ssh-keygen tool and
use the ssh-copy-id utility to copy public keys from clients on the OpenSSH server. To disable
password-based authentication on your OpenSSH server, edit /etc/ssh/sshd_config and
change the PasswordAuthentication option to no:
PasswordAuthentication no
Key types
Although the ssh-keygen command generates a pair of RSA keys by default, you can instruct it
to generate ECDSA or Ed25519 keys by using the -t option. The ECDSA (Elliptic Curve Digital
Signature Algorithm) offers better performance than RSA at the equivalent symmetric key
strength. It also generates shorter keys. The Ed25519 public-key algorithm is an implementation
of twisted Edwards curves that is more secure and also faster than RSA, DSA, and ECDSA.
OpenSSH creates RSA, ECDSA, and Ed25519 server host keys automatically if they are missing.
To configure the host key creation in RHEL 8, use the sshd-keygen@.service instantiated
service. For example, to disable the automatic creation of the RSA key type:
165
Red Hat Enterprise Linux 8 Configuring basic system settings
To exclude particular key types for SSH connections, comment out the relevant lines in
/etc/ssh/sshd_config, and reload the sshd service. For example, to allow only Ed25519 host
keys:
# HostKey /etc/ssh/ssh_host_rsa_key
# HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
Non-default port
By default, the sshd daemon listens on TCP port 22. Changing the port reduces the exposure
of the system to attacks based on automated network scanning and thus increase security
through obscurity. You can specify the port using the Port directive in the
/etc/ssh/sshd_config configuration file.
You also have to update the default SELinux policy to allow the use of a non-default port. To do
so, use the semanage tool from the policycoreutils-python-utils package:
In the previous commands, replace port_number with the new port number specified using the
Port directive.
No root login
If your particular use case does not require the possibility of logging in as the root user, you
should consider setting the PermitRootLogin configuration directive to no in the
/etc/ssh/sshd_config file. By disabling the possibility of logging in as the root user, the
administrator can audit which users run what privileged commands after they log in as regular
users and then gain root rights.
Alternatively, set PermitRootLogin to prohibit-password:
PermitRootLogin prohibit-password
This enforces the use of key-based authentication instead of the use of passwords for logging
in as root and reduces risks by preventing brute-force attacks.
The X server in Red Hat Enterprise Linux clients does not provide the X Security extension.
Therefore, clients cannot request another security layer when connecting to untrusted SSH
servers with X11 forwarding. Most applications are not able to run with this extension enabled
anyway.
By default, the ForwardX11Trusted option in the /etc/ssh/ssh_config.d/05-redhat.conf file is
set to yes, and there is no difference between the ssh -X remote_machine (untrusted host)
and ssh -Y remote_machine (trusted host) command.
If your scenario does not require the X11 forwarding feature at all, set the X11Forwarding
directive in the /etc/ssh/sshd_config configuration file to no.
166
CHAPTER 7. USING SECURE COMMUNICATIONS BETWEEN TWO SYSTEMS WITH OPENSSH
AllowUsers *@192.168.1.*,*@10.0.0.*,!*@192.168.1.2
AllowGroups example-group
The previous configuration lines accept connections from all users from systems in 192.168.1.*
and 10.0.0.* subnets except from the system with the 192.168.1.2 address. All users must be in
the example-group group. The OpenSSH server denies all other connections.
Note that using whitelists (directives starting with Allow) is more secure than using blacklists
(options starting with Deny) because whitelists block also new unauthorized users or groups.
OpenSSH uses RHEL system-wide cryptographic policies, and the default system-wide
cryptographic policy level offers secure settings for current threat models. To make your
cryptographic settings more strict, change the current policy level:
To opt-out of the system-wide crypto policies for your OpenSSH server, uncomment the line
with the CRYPTO_POLICY= variable in the /etc/sysconfig/sshd file. After this change, values
that you specify in the Ciphers, MACs, KexAlgoritms, and GSSAPIKexAlgorithms sections in
the /etc/ssh/sshd_config file are not overridden. Note that this task requires deep expertise in
configuring cryptographic options.
See Using system-wide cryptographic policies in the RHEL 8 Security hardening title for more
information.
Additional resources
Prerequisites
A remote server accepts SSH connections only from the jump host.
Procedure
1. Define the jump host by editing the ~/.ssh/config file, for example:
167
Red Hat Enterprise Linux 8 Configuring basic system settings
Host jump-server1
HostName jump1.example.com
2. Add the remote server jump configuration with the ProxyJump directive to ~/.ssh/config, for
example:
Host remote-server
HostName remote1.example.com
ProxyJump jump-server1
$ ssh remote-server
NOTE
You can specify more jump servers and you can also skip adding host definitions to the
configurations file when you provide their complete host names, for example:
$ ssh -J jump1.example.com,jump2.example.com,jump3.example.com
remote1.example.com
Change the host name-only notation in the previous command if the user names or SSH
ports on the jump servers differ from the names and ports on the remote server, for
example:
$ ssh -J
johndoe@jump1.example.com:75,johndoe@jump2.example.com:75,johndoe@jump3.e
xample.com:75 joesec@remote1.example.com:220
Additional resources
Installed documentation
sshd(8) man page documents available command-line options and provides a complete list of
supported configuration files and directories.
ssh(1) man page provides a complete list of available command-line options and supported
configuration files and directories.
scp(1) man page provides a more detailed description of the scp utility and its usage.
sftp(1) man page provides a more detailed description of the sftp utility and its usage.
168
CHAPTER 7. USING SECURE COMMUNICATIONS BETWEEN TWO SYSTEMS WITH OPENSSH
ssh-keygen(1) man page documents in detail the use of the ssh-keygen utility to generate,
manage, and convert authentication keys used by ssh.
sshd_config(5) man page provides a full description of available SSH daemon configuration
options.
Online documentation
OpenSSH Home Page - contains further documentation, frequently asked questions, links to
the mailing lists, bug reports, and other useful resources.
Configuring SELinux for applications and services with non-standard configurations - you can
apply analogous procedures for OpenSSH in a non-standard configuration with SELinux in
enforcing mode.
Controlling network traffic using firewalld - provides guidance on updating firewalld settings
after changing an SSH port
169
Red Hat Enterprise Linux 8 Configuring basic system settings
The rsyslogd daemon also provides extended filtering, encryption protected relaying of messages,
input and output modules, and support for transportation using the TCP and UDP protocols.
In /etc/rsyslog.conf, which is the main configuration file for rsyslog, you can specify the rules according
to which rsyslogd handles the messages. Generally, you can classify messages by their source and topic
(facility) and urgency (priority), and then assign an action that should be performed when a message fits
these criteria.
In /etc/rsyslog.conf, you can also see a list of log files maintained by rsyslogd. Most log files are
located in the /var/log/ directory. Some applications, such as httpd and samba, store their log files in a
subdirectory within /var/log/.
Additional resources
Prerequisites
Procedure
Verification
170
CHAPTER 8. CONFIGURING A REMOTE LOGGING SOLUTION
$ firefox file:///usr/share/doc/rsyslog/html/index.html
Prerequisites
Procedure
1. Optional: To use a different port for rsyslog traffic, add the syslogd_port_t SELinux type to
port. For example, enable port 30514:
2. Optional: To use a different port for rsyslog traffic, configure firewalld to allow incoming
rsyslog traffic on that port. For example, allow TCP traffic on port 30514 in zone zone:
3. Create a new file in the /etc/rsyslog.d/ directory named, for example, remotelog.conf, and
insert the following content:
template(name="TmplMsg" type="list") {
constant(value="/var/log/remote/msg/")
property(name="hostname")
constant(value="/")
property(name="programname" SecurePath="replace")
constant(value=".log")
}
171
Red Hat Enterprise Linux 8 Configuring basic system settings
*.info;mail.none;authpriv.none;cron.none
action(type="omfile" DynaFile="TmplMsg")
}
5. Make sure the rsyslog service is running and enabled on the logging server:
7. Optional: If rsyslog is not enabled, ensure the rsyslog service starts automatically after reboot:
Your log server is now configured to receive and store log files from the other systems in your
environment.
Verification
# rsyslogd -N 1
rsyslogd: version 8.1911.0-2.el8, config validation run (level 1), master config
/etc/rsyslog.conf
rsyslogd: End of config validation run. Bye.
Additional resources
The omfwd plug-in provides forwarding over UDP or TCP. The default protocol is UDP. Because the
plug-in is built in, it does not have to be loaded.
Prerequisites
The rsyslog package is installed on the client systems that should report to the server.
172
CHAPTER 8. CONFIGURING A REMOTE LOGGING SOLUTION
Procedure
1. Create a new file in the /etc/rsyslog.d/ directory named, for example, remotelog.conf, and
insert the following content:
*.* action(type="omfwd"
queue.type="linkedlist"
queue.filename="example_fwd"
action.resumeRetryCount="-1"
queue.saveOnShutdown="on"
target="example.com" port="30514" protocol="tcp"
)
Where:
queue.filename defines a disk storage. The backup files are created with the example_fwd
prefix in the working directory specified by the preceding global workDirectory directive,
the last line forwards all received messages to the logging server, port specification is
optional.
With this configuration, rsyslog sends messages to the server but keeps messages in memory if
the remote server is not reachable. A file on disk is created only if rsyslog runs out of the
configured memory queue space or needs to shut down, which benefits the system
performance.
Verification
To verify that the client system sends messages to the server, follow these steps:
# logger test
# cat /var/log/remote/msg/hostname/root.log
Feb 25 03:53:17 hostname root[6064]: test
Where hostname is the host name of the client system. Note that the log contains the user
173
Red Hat Enterprise Linux 8 Configuring basic system settings
Where hostname is the host name of the client system. Note that the log contains the user
name of the user that entered the logger command, in this case root.
Additional resources
The Configuring system logging without journald or with minimized journald usage
Knowledgebase article
The Negative effects of the RHEL default logging setup on performance and their mitigations
article
174
CHAPTER 9. USING PYTHON
With Red Hat Enterprise Linux, many packages that are installed on the system, such as packages
providing system tools, tools for data analysis or web applications are written in Python. To be able to
use these packages, you need to have the python packages installed.
Red Hat Enterprise Linux 8 uses Python 3.6 by default. However, Python 2.7 is also provided to support
existing software.
WARNING
IMPORTANT
Always specify the major version of Python when installing it, invoking it, or otherwise
interacting with it. For example, use python3, instead of python, in package and
command names. All Python-related commands should also include the version, for
example, pip3 or pip2.
Alternatively, configure the system default version by using the alternatives command as
described in Configuring the unversioned Python.
As a system administrator, you are recommended to use preferably Python 3 for the following reasons:
Python 2 in Red Hat Enterprise Linux 8 will have a shorter life cycle and its aim is to facilitate
smoother transition to Python 3 for customers.
Python 3 allows writing expressive, maintainable, and correct code more easily.
175
Red Hat Enterprise Linux 8 Configuring basic system settings
Python 3 has new features, including asyncio, f-strings, advanced unpacking, keyword only
arguments, chained exceptions and more.
However, existing software tends to require /usr/bin/python to be Python 2. For this reason, no default
python package is distributed with Red Hat Enterprise Linux 8, and you can choose between using
Python 2 and 3 as /usr/bin/python, as described in Section 9.2.5, “Configuring the unversioned Python” .
WARNING
Using the unversioned python command to install or run Python does not work by
default due to ambiguity. Always specify the major version of Python, or configure
the system default version by using the alternatives command.
To install Python 3.6 from the python36 module in AppStream, use the following procedure.
Procedure
For details regarding modules, see Installing, managing, and removing user-space components .
176
CHAPTER 9. USING PYTHON
WARNING
Note that Python 3 is the main development direction of the Python project. The
support for Python 2 is being phased out. The python27 module has a shorter
support period than Red Hat Enterprise Linux 8.
To install Python 2.7 from the python27 module in AppStream, use the following procedure.
Procedure
For details regarding modules, see Installing, managing, and removing user-space components .
Packages with add-on modules for Python 3 generally use the python3- prefix.
For example, to install the Requests module that is used for writing HTTP clients, use this procedure.
Procedure
Packages with add-on modules for Python 2 generally use the python2- prefix.
For example, to install the Requests module that is used for writing HTTP clients, use the following
procedure.
Procedure
177
Red Hat Enterprise Linux 8 Configuring basic system settings
System administrators can configure the unversioned python command on the system using the
alternatives command. Note that the required package, either python3 or python2, needs to be
installed before configuring the unversioned command to the respective version.
To configure the unversioned python command to Python 3 directly, use this procedure.
Procedure
To configure the unversioned python command to Python 2 directly, use this procedure.
Procedure
9.2.5.3. Configuring the unversioned python command to the required Python version
interactively
You can also configure the unversioned python command to the required Python version interactively.
Procedure
3. To reset this configuration and remove the unversioned python command, run:
WARNING
178
CHAPTER 9. USING PYTHON
Note that after this migration, the original Python 2 code becomes interpretable by the Python 3
interpreter and stays interpretable for the Python 2 interpreter as well.
You can also package your Python project into an RPM package, which provides the following
advantages compared to Setuptools packaging:
Cryptographic signing
With cryptographic signing, content of RPM packages can be verified, integrated, and tested
with the rest of the operating system.
Preamble (contains a series of metadata items that are used in the Body)
For further information about SPEC files, see Packaging and distributing software .
An RPM SPEC file for Python projects has some specifics compared to non-Python RPM SPEC files.
Most notably, a name of any RPM package of a Python library must always include the python3 prefix.
Other specifics are shown in the following SPEC file example for the python3-detox package. For
description of such specifics, see the notes below the example.
Name: python3-detox 2
Version: 0.12
Release: 4%{?dist}
Summary: Distributing activities of the tox tool
License: MIT
URL: https://pypi.io/project/detox
Source0: https://pypi.io/packages/source/d/%{modname}/%{modname}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python36-devel 3
BuildRequires: python3-setuptools
BuildRequires: python36-rpm-macros
179
Red Hat Enterprise Linux 8 Configuring basic system settings
BuildRequires: python3-six
BuildRequires: python3-tox
BuildRequires: python3-py
BuildRequires: python3-eventlet
%?python_enable_dependency_generator 4
%description
Detox is the distributed version of the tox python testing tool. It makes efficient use of multiple CPUs
by running all possible activities in parallel.
Detox has the same options and configuration that tox has, so after installation you can run it in the
same way and with the same options that you use for tox.
$ detox
%prep
%autosetup -n %{modname}-%{version}
%build
%py3_build 5
%install
%py3_install
%check
%{__python3} setup.py test 6
%files -n python3-%{modname}
%doc CHANGELOG
%license LICENSE
%{_bindir}/detox
%{python3_sitelib}/%{modname}/
%{python3_sitelib}/%{modname}-%{version}*
%changelog
...
1 The modname macro contains the name of the Python project. In this example it is detox.
2 When packaging a Python project into RPM, the python3 prefix always needs to be added to the
original name of the project. The original name here is detox and the name of the RPM is
python3-detox.
3 BuildRequires specifies what packages are required to build and test this package. In
BuildRequires, always include items providing tools necessary for building Python packages:
python36-devel and python3-setuptools. The python36-rpm-macros package is required so
that files with /usr/bin/python3 shebangs are automatically changed to /usr/bin/python3.6. For
more information, see Section 9.4.4, “Handling hashbangs in Python scripts” .
4 Every Python package requires some other packages to work correctly. Such packages need to be
specified in the SPEC file as well. To specify the dependencies, you can use the
%python_enable_dependency_generator macro to automatically use dependencies defined in
the setup.py file. If a package has dependencies that are not specified using Setuptools, specify
them within additional Requires directives.
The %py3_build and %py3_install macros run the setup.py build and setup.py install commands,
180
CHAPTER 9. USING PYTHON
5 The %py3_build and %py3_install macros run the setup.py build and setup.py install commands,
respectively, with additional arguments to specify installation locations, the interpreter to use, and
6 The check section provides a macro that runs the correct version of Python. The %{__python3}
macro contains a path for the Python 3 interpreter, for example /usr/bin/python3. We recommend
to always use the macro rather than a literal path.
.dist-info
.egg-info
.egg-link
From these directories, the RPM build process automatically generates virtual pythonX.Ydist provides,
for example python3.6dist(detox). These virtual provides are used by packages that are specified by
the %python_enable_dependency_generator macro.
181
Red Hat Enterprise Linux 8 Configuring basic system settings
In Red Hat Enterprise Linux 8, executable Python scripts are expected to use hashbangs (shebangs)
specifying explicitly at least the major Python version.
NOTE
The BRP script generates errors when encountering a Python script with an ambiguous
hashbang, such as:
#! /usr/bin/python
or
#! /usr/bin/env python
To modify hashbangs in the Python scripts that cause the build errors at RPM build time, use this
procedure.
Procedure
Note that multiple PATHs can be specified. If a PATH is a directory, pathfix.py recursively
scans for any Python scripts matching the pattern ^[a-zA-Z0-9_]+\.py$, not only those with an
ambiguous hashbang. Add this command to the %prep section or at the end of the %install
section.
Alternatively, modify the packaged Python scripts so that they conform to the expected format. For this
purpose, pathfix.py can be used outside the RPM build process, too. When running pathfix.py outside a
RPM build, replace __python3 from the example above with a path for the hashbang, such as
/usr/bin/python3.
If the packaged Python scripts require Python version 2, replace the number 3 with 2 in the commands
above.
Additionally, hashbangs in the form /usr/bin/python3 are by default replaced with hashbangs pointing to
Python from the platform-python package used for system tools with Red Hat Enterprise Linux.
To change the /usr/bin/python3 hashbangs in their custom packages to point to a version of Python
installed from Application Stream, in the form /usr/bin/python3.6, ue the following procedure.
Procedure
Add the python36-rpm-macros package into the BuildRequires section of the SPEC file by
including the following line:
182
CHAPTER 9. USING PYTHON
BuildRequires: python36-rpm-macros
NOTE
To prevent hashbang check and modification by the BRP script, use the following RPM
directive:
%undefine %brp_mangle_shebangs
183
Red Hat Enterprise Linux 8 Configuring basic system settings
On a Red Hat Enterprise Linux 8 system, langpacks installation is based on the langpacks-<langcode>
language meta-packages and RPM weak dependencies (Supplements tag).
There are two prerequisites to be able to use langpacks for a selected language. If these prerequisites
are fulfilled, the language meta-packages pull their langpack for the selected language automatically in
the transaction set.
Prerequisites
The langpacks-<langcode> language meta-package for the selected language has been
installed on the system.
On Red Hat Enterprise Linux 8, the langpacks meta packages are installed automatically with
the initial installation of the operating system using the Anaconda installer, because these
packages are available in the in Application Stream repository.
For more information, see Section 10.1, “Checking languages that provide langpacks”
The base package, for which you want to search the local packages, has already been installed on
the system.
Procedure
Procedure
184
CHAPTER 10. USING LANGPACKS
To check if language support is available for any language, use the following procedure.
Procedure
Procedure
Procedure
Procedure
On systems where disk space is a critical issue, such as containers and cloud images, or only a few locales
are needed, you can use the glibc locale langpack packages (glibc-langpack-<locale_code>).
To install locales individually, and thus gain a smaller package installation footprint, use the following
procedure.
Procedure
185
Red Hat Enterprise Linux 8 Configuring basic system settings
When installing the operating system with Anaconda, glibc-langpack-<locale_code> is installed for the
language you used during the installation and also for the languages you selected as additional
languages. Note that glibc-all-langpacks, which contains all locales, is installed by default, so some
locales are duplicated. If you installed glibc-langpack-<locale_code> for one or more selected
languages, you can delete glibc-all-langpacks after the installation to save the disk space.
NOTE
If disk space is not an issue, keep all locales installed by using the glibc-all-langpacks
package.
186
CHAPTER 11. GETTING STARTED WITH TCL/TK
Using Tcl paired with Tk (Tcl/Tk) enables creating cross-platform GUI applications. Tk is provided by
the tk package.
A Tk C library bindings available for multiple languages, such as C, Ruby, Perl and Python
For more information about Tcl/Tk, see the Tcl/Tk manual or Tcl/Tk documentation web page .
List processing
Two new commands, lmap and dict map are available, which allow the expression of
transformations over Tcl containers.
187
Red Hat Enterprise Linux 8 Configuring basic system settings
Busy windows
A new command, tk busy is available, which disables user interaction for a window or a widget
and shows the busy cursor.
For the detailed list of changes between Tcl 8.5 and Tcl 8.6, see Changes in Tcl/Tk 8.6 .
Developers writing Tcl extensions or embedding Tcl interpreter into their applications
Procedure
1. Rewrite the code to use the interp structure. For example, if your code reads
interp→errorLine, rewrite it to use the following function:
Tcl_GetErrorLine(interp)
This is necessary because Tcl 8.6 limits direct access to members of the interp structure.
2. To make your code compatible with both Tcl 8.5 and Tcl 8.6, use the following code snippet in
a header file of your C or C++ application or extension that includes the Tcl library:
# include <tcl.h>
# if !defined(Tcl_GetErrorLine)
# define Tcl_GetErrorLine(interp) (interp→errorLine)
# endif
11.3.2. Migration path for users scripting their tasks with Tcl/Tk
In Tcl 8.6, most scripts work the same way as with the previous version of Tcl.
Procedure
When writing a portable code, make sure to not use the commands that are no longer supported
in Tk 8.6:
188
CHAPTER 11. GETTING STARTED WITH TCL/TK
tkIconList_Arrange
tkIconList_AutoScan
tkIconList_Btn1
tkIconList_Config
tkIconList_Create
tkIconList_CtrlBtn1
tkIconList_Curselection
tkIconList_DeleteAll
tkIconList_Double1
tkIconList_DrawSelection
tkIconList_FocusIn
tkIconList_FocusOut
tkIconList_Get
tkIconList_Goto
tkIconList_Index
tkIconList_Invoke
tkIconList_KeyPress
tkIconList_Leave1
tkIconList_LeftRight
tkIconList_Motion1
tkIconList_Reset
tkIconList_ReturnKey
tkIconList_See
tkIconList_Select
tkIconList_Selection
tkIconList_ShiftBtn1
tkIconList_UpDown
Note that you can check the list of unsupported commands also in the
/usr/share/tk8.6/unsupported.tcl file.
189
Red Hat Enterprise Linux 8 Configuring basic system settings
However, Red Hat recommends to use the default naming scheme, which is the same as in Red Hat
Enterprise Linux 7.
For more details about this scheme, see Consistent Network Device Naming .
To set and activate the required prefix for your Ethernet network interfaces, use the following
procedure.
Procedure
net.ifnames.prefix=<required prefix>
WARNING
Red Hat does not support the use of prefixdevname on already deployed systems.
After the prefix was once set, and the operating system was rebooted, the prefix is effective every time
when a new network interface appears. The new device is assigned a name in the form of <PREFIX>
<INDEX>. For example, if your selected prefix is net, and the interfaces with net0 and net1 prefixes
already exist on the system, the new interface is named net2. The prefixdevname utility then generates
the new .link file in the /etc/systemd/network directory that applies the name to the interface with the
MAC address that just appeared. The configuration is persistent across reboots.
The prefix that you choose must meet the following requirements:
Be ASCII string
190
CHAPTER 12. USING PREFIXDEVNAME FOR NAMING OF ETHERNET NETWORK INTERFACES
Be alphanumeric string
WARNING
The prefix cannot conflict with any other well-known prefix used for network
interface naming on Linux. Specifically, you cannot use these prefixes: eth, eno,
ens, em.
191