Red Hat Enterprise Linux 9 Administration: A comprehensive Linux system administration guide for RHCSA certification exam candidates
()
About this ebook
With Red Hat Enterprise Linux 9 becoming the standard for enterprise Linux used from data centers to the cloud, Linux administration skills are in high demand. With this book, you’ll learn how to deploy, access, tweak, and improve enterprise services on any system on any cloud running Red Hat Enterprise Linux 9.
Throughout the book, you’ll get to grips with essential tasks such as configuring and maintaining systems, including software installation, updates, and core services. You’ll also understand how to configure the local storage using partitions and logical volumes, as well as assign and deduplicate storage. You’ll learn how to deploy systems while also making them secure and reliable.
This book provides a base for users who plan to become full-time Linux system administrators by presenting key command-line concepts and enterprise-level tools, along with essential tools for handling files, directories, command-line environments, and documentation for creating simple shell scripts or running commands. With the help of command line examples and practical tips, you’ll learn by doing and save yourself a lot of time.
By the end of the book, you’ll have gained the confidence to manage the filesystem, users, storage, network connectivity, security, and software in RHEL 9 systems on any footprint.
Related to Red Hat Enterprise Linux 9 Administration
Related ebooks
RedHat Enterprise Linux 9 for Beginners: A comprehensive guide for learning, administration, and deployment (English Edition) Rating: 0 out of 5 stars0 ratingsRed Hat Ansible Third Edition Rating: 0 out of 5 stars0 ratingsRed Hat Ceph A Complete Guide Rating: 0 out of 5 stars0 ratingsOpenStack Networking Cookbook Rating: 0 out of 5 stars0 ratingsLearning SaltStack Rating: 4 out of 5 stars4/5Red Hat Ceph Storage A Clear and Concise Reference Rating: 0 out of 5 stars0 ratingsRed Hat Ansible A Complete Guide - 2019 Edition Rating: 0 out of 5 stars0 ratingsCommvault Simpana A Complete Guide - 2019 Edition Rating: 0 out of 5 stars0 ratingsNetBackup Complete Self-Assessment Guide Rating: 5 out of 5 stars5/5Red Hat RHCE 8 (EX294) Capsules: Certification Guide Rating: 0 out of 5 stars0 ratingsDRBD-Cookbook: How to create your own cluster solution, without SAN or NAS! Rating: 0 out of 5 stars0 ratingsIBM BigFix A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsVMware Certified Professional Second Edition Rating: 1 out of 5 stars1/5WebSphere Application Server 7.0 Administration Guide Rating: 0 out of 5 stars0 ratingsTroubleshooting CentOS Rating: 0 out of 5 stars0 ratingsCommvault Simpana A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsIBM i5/iSeries Primer: Concepts and Techniques for Programmers, Administrators, and System Operators Rating: 0 out of 5 stars0 ratingsWildFly Cookbook Rating: 0 out of 5 stars0 ratingsAnsible For Linux by Examples Rating: 0 out of 5 stars0 ratingsNetstat A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsVMware vCenter Cookbook Rating: 0 out of 5 stars0 ratingsRHCSA Exam Pass: Red Hat Certified System Administrator Study Guide Rating: 0 out of 5 stars0 ratingsIntroducing Microsoft SQL Server 2019: Reliability, scalability, and security both on premises and in the cloud Rating: 0 out of 5 stars0 ratingsSystem Center 2012 R2 Virtual Machine Manager Cookbook Rating: 0 out of 5 stars0 ratingsRed Hat Certified Architect A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsCentOS Stream 9 Essentials: Learn to Install, Administer, and Deploy CentOS Stream 9 Systems Rating: 0 out of 5 stars0 ratingsMastering SaltStack Rating: 0 out of 5 stars0 ratingsMastering CSS Grid: A comprehensive and practical guide to creating beautiful layouts with CSS Grid Rating: 0 out of 5 stars0 ratingsCitrix XenApp Performance Essentials Rating: 0 out of 5 stars0 ratings
System Administration For You
CompTIA A+ Complete Review Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 5 out of 5 stars5/5Learning Microsoft Endpoint Manager: Unified Endpoint Management with Intune and the Enterprise Mobility + Security Suite Rating: 0 out of 5 stars0 ratingsLinux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Bash Command Line Pro Tips Rating: 5 out of 5 stars5/5Cybersecurity: The Beginner's Guide: A comprehensive guide to getting started in cybersecurity Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5Learn PowerShell Scripting in a Month of Lunches Rating: 0 out of 5 stars0 ratingsWordpress 2023 A Beginners Guide : Design Your Own Website With WordPress 2023 Rating: 0 out of 5 stars0 ratingsPractical Data Analysis Rating: 4 out of 5 stars4/5Learn SQL Server Administration in a Month of Lunches Rating: 3 out of 5 stars3/5Ethical Hacking Rating: 4 out of 5 stars4/5Easy Linux For Beginners Rating: 2 out of 5 stars2/5Linux Bible Rating: 0 out of 5 stars0 ratingsPowerShell: A Beginner's Guide to Windows PowerShell Rating: 4 out of 5 stars4/5Linux Commands By Example Rating: 5 out of 5 stars5/5The Complete Powershell Training for Beginners Rating: 0 out of 5 stars0 ratingsFreeBSD Mastery: Jails: IT Mastery, #15 Rating: 5 out of 5 stars5/5Building a Plex Server with Raspberry Pi Rating: 0 out of 5 stars0 ratingsManaging Data Using Excel Rating: 5 out of 5 stars5/5Mastering Linux Network Administration Rating: 4 out of 5 stars4/5Git Essentials Rating: 4 out of 5 stars4/5PowerShell: A Comprehensive Guide to Windows PowerShell Rating: 4 out of 5 stars4/5Linux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsMastering Bash Rating: 5 out of 5 stars5/5Nmap: Network Exploration and Security Auditing Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsMastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5
Reviews for Red Hat Enterprise Linux 9 Administration
0 ratings0 reviews
Book preview
Red Hat Enterprise Linux 9 Administration - Pablo Iranzo Gómez
BIRMINGHAM—MUMBAI
Red Hat Enterprise Linux 9 Administration
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Mohd Riyan Khan
Publishing Product Manager: Shrilekha Malpani
Senior Editor: Romy Dias
Technical Editor: Arjun Varma
Copy Editor: Safis Editing
Project Coordinator: Ashwin Kharwa
Proofreader: Safis Editing
Indexer: Manju Arasan
Production Designer: Aparna Bhagat
Marketing Coordinator: Nimisha Dua
First published: November 2021
Second edition: October 2022
Production reference: 1211022
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80324-880-6
www.packt.com
To all the people contributing to and being part of open source, building it one piece at a time, and pushing its boundaries to make huge things possible.
– Pablo Iranzo Gómez
To the ones that once crossed my path and made a difference.
– Pedro Ibáñez Requena
Contributors
About the authors
Pablo Iranzo Gómez is a software engineer who started his Linux exposure while studying physics. He was also involved in LUGs and some projects related to HPC clusters and system administration and consultancy.
Currently, he is a principal software engineer at Red Hat’s TelCo 5G OpenShift management integration department, leveraging his experience in consulting, cloud technical account management, and OpenStack software maintenance in industries such as hotel, retail, airlines, government, Telco, 5G, Partner, and IT – covering system administration and automation, virtualization, PaaS, support, the cloud, and so on. He has a broad understanding of different views, needs, and risks across the industry.
Pablo was born in and lives in Valencia, Spain, with his family.
I want to thank my wife, Eva and my sons, Pau and Roi, for the support provided while working on this project, Javier for the moral support provided during this writing, and Miquel for always being there. Not forgetting about Miguel, who gave me this opportunity and helped get the prior version ready, and, of course, the whole Packt team that has been helping, guiding, and advising during the whole process.
Pedro Ibáñez Requena is a software engineer who started his Linux adventure playing with Linux distributions provided on CDs by magazines. He was also involved in LUGs while studying software engineering at Universitat de València.
Currently, he is a principal systems engineer in Red Hat’s Telco 5G field engineering team, focusing on OpenShift, with experience in automation, security, high availability, and databases. His experience was built in industries such as retail, finance, insurance, and Telco. He has been involved in the design, configuration, and deployment of complex IT systems including data storage, networking, monitoring, and PaaS and SaaS systems where he has a broad understanding of different views, needs, and risks across the industry.
Pedro was born in Alcoy and lives in Valencia, Spain, with his family.
I want to thank my girls, Katja and Maya, for the endless days at home, playing, chatting, swimming, traveling, or discussing because, without them, I wouldn’t be who I am today. To my parents, for supporting me to study what I wanted and for providing when I needed it. To Carles and Alex, because their help in this race was life-changing. To Pablo, who thought about me helping him with this book, and lastly, to all the people that make my day, the Telco 5G field engineering team, and the Packt team that made this possible.
Miguel Pérez Colino is an experienced technology enthusiast with a clear orientation toward IT, free/open source software, and open standards. His career has grown in the IT field with connections in every direction. From user support and teaching; through systems and network administration; to systems engineering, systems architecture, IT strategy definition, and now, as a senior manager for the Tanzu portfolio to bring Kubernetes closer to customers. He loves designing solutions and tools, making them useful and easy to use.
Scott McCarty is a principal product manager at Red Hat for the container subsystem team, which enables key product capabilities in OpenShift Container Platform and Red Hat Enterprise Linux. His focus areas include container runtimes, tools, and images. Scott is a social media start-up veteran, an e-commerce old-timer, and a weathered government research technologist, with experience across a variety of companies and organizations, from 7-person start-ups to 15,000-employee technology companies. This has culminated in a unique perspective on open source software development, delivery, and maintenance.
About the reviewers
Derek Thurston is a senior solutions architect at Red Hat and has been working with open source software since the mid-1990s. After graduating from a small merchant marine college in coastal Maine, Derek landed a job in the IT department
at a naval architecture firm in Arlington, VA, where he started using Linux. Derek has worked with SGI and HP/UX systems and did his part to help save the world by converting COBOL programs to four-digit years in the late 1990s. Having worked with a variety of public and private sector entities, he has spent over 25 years helping customers find the right open source tools and technologies.
I would like to thank my wife, who inspires me every day, my son, who is always down for a cool adventure, and my two dogs, who are my steadfast officemates.
Luis Sampaio is a system engineer. He has managed servers since 2010. He has experience with Red Hat, Ubuntu, and Debian. He has some certifications such as RHCE and RHCSA.
Luis has diverse experiences in different private, hybrid cloud architectures with Amazon Web Services and Azure, as well as experience with DevOps tools such as Ansible and containers.
He likes to share his tech views and experiments with a community. Luis loves playing poker with friends and visiting new cities.
I would like to thank my family (my mother, Silvia, for all the support, my wonderful wife, Yolanda, and my terrific and smart son, Bruno Miguel) for unlimited patience and tolerance.
My wife is my best friend, and I love her dearly. Without her love and the support from her, I would never have been able to finish the book.
Table of Contents
Preface
Part 1 – Systems Administration – Software, User, Network, and Services Management
1
Getting RHEL Up and Running
Technical requirements
Obtaining RHEL and a subscription
Installing RHEL 9
Preparation for a physical server installation
Preparation for a virtual server installation
Running an RHEL installation
Summary
2
RHEL 9 Advanced Installation Options
Technical requirements
Automating RHEL deployments with Anaconda
Deploying RHEL on the cloud
Installation best practices
Summary
3
Basic Commands and Simple Shell Scripts
Logging in as a user and managing multi-user environments
Using the root account
Using and understanding the command prompt
Changing users with the su command
Understanding users, groups, and basic permissions
Users
Groups
File permissions
Using the command line, environment variables, and navigating through the filesystem
Command line and environment variables
Navigating the filesystem
Bash auto-complete
The filesystem hierarchy
Understanding I/O redirection on the command line
Filtering output with grep and sed
Listing, creating, copying, and moving files, directories, links, and hard links
Directories
Copying and moving
Symbolic and hard links
Using tar and gzip
Creating basic shell scripts
for loops
if conditionals
Exit codes
Using system documentation resources
man pages
info pages
Other documentation resources
Summary
4
Tools for Regular Operations
Technical requirements
Managing system services with systemd
systemd unit file structure
Managing services to be started and stopped at boot
Managing boot targets
Scheduling tasks with cron and systemd
System-wide crontab
User crontab
systemd timers
Learning about time synchronization with chrony and NTP
NTP client
NTP server
Checking for free resources – memory and disk (free and df)
Memory
Disk space
CPU
Load average
Other monitoring tools
Finding logs, using journald, and reading log files, including log preservation and rotation
Log rotation
Summary
5
Securing Systems with Users, Groups, and Permissions
Creating, modifying, and deleting local user accounts and groups
Managing groups and reviewing assignments
Adjusting password policies
Configuring sudo access for administrative tasks
Understanding sudo configuration
Using sudo to run admin commands
Configuring sudoers
Checking, reviewing, and modifying file permissions
Using special permissions
Understanding and applying SUID
Understanding and applying SGID
Using the sticky bit
Summary
6
Enabling Network Connectivity
Technical requirements
Exploring network configuration in RHEL
Getting to know the configuration files and NetworkManager
Configuring network interfaces with IPv4 and IPv6
IPv4 and IPv6 – what do they mean?
Configuring interfaces with nmtui
Configuring interfaces with nm-connection-editor
Configuring interfaces with nmcli
Where does NetworkManager store configuration?
Configuring hostname and hostname resolutions (DNS)
An overview of firewall configuration
Configuring the firewall
Testing network connectivity
Summary
7
Adding, Patching, and Managing Software
RHEL subscription registration and management
Managing repositories and signatures with yum/dnf
Doing software installations, updates, and rollbacks with YUM/DNF
Creating and syncing repositories with createrepo and reposync
Understanding RPM internals
Summary
Part 2 – Security with SSH, SELinux, a Firewall, and System Permissions
8
Administering Systems Remotely
Technical requirements
SSH and OpenSSH overview and base configuration
OpenSSH server
OpenSSH client
Enabling root access via SSH (and when not to do it)
Accessing remote systems with SSH
Key-based authentication with SSH
SSH agent
Remote file management with SCP/rsync
Transferring files with an OpenSSH secure file copy
Transferring files with sftp
Transferring files with rsync
Advanced remote management – SSH tunnels and SSH redirections
Remote terminals with tmux
Introduction to Ansible automation
Inventory
Playbook
Summary
9
Securing Network Connectivity with firewalld
Introduction to the RHEL firewall – firewalld
Enabling firewalld in the system and reviewing the default zones
Reviewing the different configuration items under firewalld
Enabling and managing services and ports
Creating and using service definitions for firewalld
Configuring firewalld with the web interface
Summary
10
Keeping Your System Hardened with SELinux
Technical requirements
SELinux usage in enforcing and permissive modes
Reviewing the SELinux context for files and processes
Tweaking the policy with semanage
Restoring changed file contexts to the default policy
Using SELinux Boolean settings to enable services
SELinux troubleshooting and common fixes
Integrity Measurement Architecture, digital hashes, and signatures for enhancing security
EVM and trusted keys
Enabling IMA and EVM in the system kernel
Summary
11
System Security Profiles with OpenSCAP
Getting started with OpenSCAP and discovering system vulnerabilities
Using OpenSCAP with security profiles for OSPP and PCI DSS
Scanning for OSPP compliance
Scanning for PCI DSS compliance
Summary
Part 3 – Resource Administration – Storage, Boot Process, Tuning, and Containers
12
Managing Local Storage and Filesystems
Technical requirements
Let’s start with a definition
A bit of history
Partitioning disks (MBR and GPT disks)
Formatting and mounting filesystems
Setting default mounts and options in fstab
Using network filesystems with NFS
Summary
13
Flexible Storage Management with LVM
Technical requirements
Understanding LVM
Creating, moving, and removing physical volumes
Combining physical volumes into volume groups
Creating and extending logical volumes
Adding new disks to a volume group and extending an logical volume
Removing logical volumes, volume groups, and physical volumes
Reviewing LVM commands
Summary
14
Advanced Storage Management with Stratis and VDO
Technical requirements
Understanding Stratis
Installing and enabling Stratis
Managing storage pools and filesystems with Stratis
Preparing systems to use VDO
Creating and using a VDO volume
Testing a VDO volume and reviewing the stats
Summary
15
Understanding the Boot Process
Understanding the boot process – BIOS and UEFI booting
Working with GRUB, the bootloader, and the initrd system images
Managing the boot sequence with systemd
Intervening in the boot process to gain access to a system
Summary
16
Kernel Tuning and Managing Performance Profiles with tuned
Technical requirements
Identifying processes, checking memory usage, and killing processes
Adjusting kernel scheduling parameters to better manage processes
Installing tuned and managing tuning profiles
Creating a custom tuned profile
Using the web console for observing performance metrics
Summary
17
Managing Containers with Podman, Buildah, and Skopeo
Technical requirements
Introduction to containers
Installing container tools
Running a container using Podman and UBI
Basic container management – pull, run, stop, and remove
Attaching persistent storage to a container
Deploying a container on a production system with systemd
Building a container image using a Dockerfile or Containerfile
Configuring Podman to search registry servers
Summary of Podman options
When to use Buildah and Skopeo
Building container images with Buildah
Inspecting a remote container with Skopeo
Summary
Part 4 – Practical Exercises
18
Practice Exercises – 1
Technical requirements
Tips for the exercise
Practice exercise 1
Exercise 1 solution
19
Practice Exercise – 2
Technical requirements
Tips for the exercise
Practice exercise 2
Exercise 2 resolution
Index
Other Books You May Enjoy
Preface
Linux is everywhere, from personal devices to the largest supercomputers, from the computer labs at universities to Wall Street or the International Space Station, and even Mars! Red Hat Enterprise Linux (RHEL) is the most used Linux distribution in enterprise environments and knowing how to use it is a key skill for anyone in technology. No matter whether you are completely into managing infrastructure or you are a developer interested in knowing more about the platform you want to deploy on, learning about Linux – and, more precisely, about RHEL – will help you be more effective and could even boost your career.
In this book, we cover the basic RHEL administration skills from a very practical perspective, providing examples and tips that we have learned from our experience in the trenches.
You will be able to follow it from beginning to end, being able to practice with each step while learning about how things are built and why they behave as they do.
We hope you enjoy this book, that you make the most of it, and that you end up, after reading it, with a strong foundation of RHEL administration skills. That’s what we wrote it for.
Enjoy reading...and practicing!
Who this book is for
Anyone that aspires to build and work on IT infrastructures using Linux will benefit from this book as a reference for different useful tasks, tips, and best practices. It will help anyone seeking to pass the Red Hat Certified Systems Administrator (RHCSA) exam, although it will be no substitute for the official training, in which labs and specially crafted tests will be run during the whole process. The scope of the book is adjusted to the RHCSA, extending it with advice from real-world experience and many practical examples.
What this book covers
Chapter 1, Getting RHEL Up and Running, covers the installation of RHEL, from obtaining the software and the subscriptions to the installation of the system itself.
Chapter 2, RHEL 9 Advanced Installation Options, introduces advanced use cases for the installer, including deploying instances in the cloud and automating the installation.
Chapter 3, Basic Commands and Simple Shell Scripts, explains the daily commands that will be used during system administration, and how can they be automated via shell scripting.
Chapter 4, Tools for Regular Operations, shows the simple tools that are available in our system that can be used for regular daily operations, such as starting or enabling a system service or reviewing what is going on in the system through logs.
Chapter 5, Securing Systems with Users, Groups, and Permissions, covers how to manage users, groups, and permissions in any Linux system, with some specifics on RHEL.
Chapter 6, Enabling Network Connectivity, goes through the steps to connect a system to the network and the possible ways it can be configured.
Chapter 7, Adding, Patching, and Managing Software, reviews how the steps to add, remove, and update can be managed in our system, including examples for upgrades and rollbacks.
Chapter 8, Administering Systems Remotely, covers how to remotely connect to your system in order to be more effective. It includes using ssh connections to create keys and using a terminal multiplexer (tmux).
Chapter 9, Securing Network Connectivity with firewalld, instructs you on how the network firewall configuration works in RHEL and how to properly manage it, including managing zones, services, and ports.
Chapter 10, Keeping Your System Hardened with SELinux, covers usage and basic troubleshooting of SELinux.
Chapter 11, System Security Profiles with OpenSCAP, explains how to run security profiles with OpenSCAP and check compliance in RHEL with typical regulations.
Chapter 12, Managing Local Storage and Filesystems, covers filesystem creation, mount points, and general storage management.
Chapter 13, Flexible Storage Management with LVM, explains how Logical Volume Manager (LVM) empowers more flexible storage management by being able to add disks and extend logical volumes.
Chapter 14, Advanced Storage Management with Stratis and VDO, introduces Virtual Data Optimizer (VDO) and how it can be used in our system to deduplicate storage, as well as using Stratis to manage storage more easily.
Chapter 15, Understanding the Boot Process, explains how the system boots and the details that make it important.
Chapter 16, Kernel Tuning and Managing Performance Profiles with tuned, explains how kernel tunning works and how to use tuned for predefined profile usage.
Chapter 17, Managing Containers with Podman, Buildah, and Skopeo, covers containers and tools for managing and building them.
Chapter 18, Practice Exercises – 1, allows you to test your acquired knowledge.
Chapter 19, Practice Exercises – 2, gives more complex testing of your acquired knowledge.
To get the most out of this book
All software requirements will be indicated in the chapters. Note that this book assumes that you have access to a physical or virtual machine, or have access to the internet to create a cloud account in order to perform the operations that the book will guide you through.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Red-Hat-Enterprise-Linux-RHEL-9-Administration. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/NcDqa.
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: Mount the downloaded RHEL9.iso disk image file as another disk in your system.
A block of code is set as follows:
#!/bin/bash
echo Hello world
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
[default]
branch = main
repo = myrepo
username = bender
protocol = https
Any command-line input or output is written as follows:
$ mkdir scripts
$ cd scripts
Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: Select System info from the Administration panel.
Tips or Important Notes
Appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Share your thoughts
Once you’ve read Red Hat Enterprise Linux 9 Administration, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Download a free PDF copy of this book
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere? Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link below
https://packt.link/free-ebook/9781803248806
Submit your proof of purchase
That’s it! We’ll send your free PDF and other benefits to your email directly
Part 1 – Systems Administration – Software, User, Network, and Services Management
Deploying and configuring systems and keeping them up to date is the base task that every system administrator performs in their day-to-day work. In this part, the core parts of doing so are explored in a restructured way so that you can follow the tasks one by one and learn, practice, and understand them properly.
The following chapters are included in this part:
Chapter 1, Getting RHEL Up and Running
Chapter 2, RHEL 9 Advanced Installation Options
Chapter 3, Basic Commands and Simple Shell Scripts
Chapter 4, Tools for Regular Operations
Chapter 5, Securing Systems with Users, Groups, and Permissions
Chapter 6, Enabling Network Connectivity
Chapter 7, Adding, Patching, and Managing Software
1
Getting RHEL Up and Running
The first step to start working with Red Hat Enterprise Linux (RHEL) is to have it running. Whether on your own laptop as the main system, on a virtual machine, or on a physical server, its installation is necessary in order to get your hands on the system you want to learn to use. It is highly encouraged that you get yourself a physical or virtual machine to use the system while reading this book.
In this chapter, you will deploy your own RHEL 9 system to be able to follow all the examples mentioned in this book, as well as discover more about Linux.
The topics to be covered in this chapter are as follows:
Obtaining RHEL software and a subscription
Installing RHEL 9
Technical requirements
The best way to get started is by having an RHEL 9 virtual machine to work with. You can do it on your main computer as a virtual machine or using a physical machine. In the following section, we will review both options and you will be able to run your own RHEL 9 system.
Tip
A virtual machine is a way to emulate a complete computer. To be able to create this emulated computer on your own laptop, if you are using macOS or Windows, you will need to install virtualization software such as VirtualBox, for example. If you are running Linux, it is already prepared for virtualization, and you will only need to add the virt-manager package.
Obtaining RHEL and a subscription
To be able to deploy RHEL, you will need a Red Hat subscription to obtain the images to be used, as well as access to repositories with software and updates. You can obtain, free of charge, a developer subscription from the developers’ portal site of Red Hat using the following link: https://developers.redhat.com/. You then need to follow these steps:
Log in or create an account at https://developers.redhat.com/.
Click on the Log in button:
Figure 1.1 – The developers.redhat.com home page, indicating where to click to log inFigure 1.1 – The developers.redhat.com home page, indicating where to click to log in
Once on the login page, use your account or, if you do not have one, create one by clicking on Register in the top-right corner or on the Register for a Red Hat account button directly in the registration box, as follows:
Figure 1.2 – Red Hat login page (common to all Red Hat resources)Figure 1.2 – Red Hat login page (common to all Red Hat resources)
You can choose to use your credentials in several services (in other words, Google, GitHub, or Twitter) if you prefer to do so.
Once you have logged in, go to the Products section in the top bar. You can find the Red Hat Enterprise Linux section in the navigation bar before the content:
Figure 1.3 – Accessing the Linux page at developers.redhat.comFigure 1.3 – Accessing the Linux page at developers.redhat.com
Click on Download RHEL at no-cost, which appears as a red button on the next page:
Figure 1.4 – Accessing the RHEL download page at developers.redhat.comFigure 1.4 – Accessing the RHEL download page at developers.redhat.com
Then, the ISO image for the x86_64 (8 GB) architecture will start downloading:
Figure 1.5 – Download dialog for RHEL 9Figure 1.5 – Download dialog for RHEL 9
The ISO image is a file that contains an exact copy of the contents of a full DVD (even when we are not using a DVD). This file will later be used to install our machines, whether dumping it to a USB drive for bare metal installations, unpacking it for network installations, or attaching it for virtual machine installations (or using out-of-band capabilities in servers such as IPMI, iLO, or iDRAC)
Tip
To verify the ISO image, and ensure that the one we have obtained is not corrupted or altered, a mechanism called checksum can be used. Checksums are a way to review a file and provide a set of letters and numbers that can be used to verify that the file is precisely the same one as in the origin. Red Hat provides a list of sha256 checksums for doing so in the downloads section of the customer portal (access.redhat.com). An article describing the process is available here: https://access.redhat.com/solutions/8367.
We have the software, in this case, the ISO image, to install RHEL 9 on any computer. These are the same bits that are used in production machines worldwide, and that you can use yourself for learning purposes with your developer subscription. Now, it is time to give them a go in the next section.
Installing RHEL 9
In this section, we will follow the typical installation process to have RHEL installed on a machine. We will follow the default steps, reviewing the options available for each one.
Preparation for a physical server installation
A physical server requires some initial setup before beginning with installation. Common steps include configuring the disks in the internal array, connecting it to the networks, preparing the switches for any interface aggregation that is expected (teaming, bonding), preparing access to external disk arrays (in other words, fiber channel arrays), setting up out-of-band capabilities, and securing the BIOS configuration.
We will not get into the details of these preparations, except for the boot sequence. The server will require to boot (start loading the system) from an external device such as a USB thumb drive or optical disk (whether physical or emulated through the out-of-band capabilities).
Creating a bootable USB thumb drive from a machine with Linux or macOS is as simple as doing a disk dump
with the dd application. Perform the following steps:
Find your USB device in the system, usually /dev/sdb in Linux, or /dev/disk2 in macOS (in macOS, this command requires special privileges; please run it as sudo dmesg | grep removable):
$ dmesg | grep removable
[66931.429805] sd 0:0:0:0: [sdb] Attached SCSI removable disk
Important Note
Please verify the disk name very carefully, as the procedure for using disk dump
will completely overwrite the disk target.
Check whether the USB is mounted and if so, dismount it (for macOS users, please use diskutil list to ascertain whether the device is mounted):
$ lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:0 1 3,8G 0 disk
├─sdb1 8:1 1 1,8G 0 part /run/media/miguel/USB
├─sdb2 8:2 1 10,9M 0 part
└─sdb3 8:3 1 22,9M 0 part
In this case, only partition one of the sdb disk, referred to as sdb1, is mounted. We will need to unmount all the partitions mounted. In this example, this is straightforward as there is only one. To do so, we can run the following command:
$ sudo umount /dev/sdb1
Important Note
By using super-user do (sudo) for administrative tasks such as unmounting devices, we can open an administrator shell (root in Linux and Unix-like systems) or run the command using sudo, which provides administrative privileges to the current user. When running commands with sudo, the user will be requested to enter their password (not the admin password, but the user’s own password) to proceed with the execution (this default behavior may be overridden in the sudoers configuration file).
Dump the image! (Warning, this will erase the selected disk!):
$ sudo dd if=rhel-baseos-9.0-beta-x86_64-dvd.iso of=/dev/sdb bs=512k
Tip
Alternative graphical tools are available for creating a boot device that can help select both the image and the target device. In Fedora Linux (the development branch used to create Red Hat Enterprise Linux, and a workstation for many engineers and developers), the Fedora Media Writer tool can be used. For other environments, the UNetbootin tool could also serve to create your boot media.
Now, with the USB thumb drive, we can install any physical machine, from a tiny laptop to a huge server. The next part involves making the physical machine boot from the USB thumb drive. The mechanism for doing that will depend on the server being used. However, it is becoming common to offer an option to select a boot device during bootup. The following is an example of how to select a temporary boot device for a laptop:
Interrupt the normal startup. In this case, the boot process shows that I can do that by pressing Enter:
Figure 1.6 – Example of a BIOS message to interrupt normal startupFigure 1.6 – Example of a BIOS message to interrupt normal startup
Choose a temporary startup device, in this case, by pressing the F12 key:
Figure 1.7 – Example of a BIOS menu for interrupted startupFigure 1.7 – Example of a BIOS menu for interrupted startup
Select the device to boot from. We want to boot from our USB thumb drive, which, in this case, is USB HDD: ChipsBnk Flash Disk:
Figure 1.8 – Example of a BIOS menu to choose the USB HDD boot deviceFigure 1.8 – Example of a BIOS menu to choose the USB HDD boot device
Let the system start the installer from the USB drive.
Once we know how to prepare a USB drive with an RHEL installer and how to make a physical machine boot from it, we can skip to the Running an RHEL installation section and proceed to install it. This can be pretty useful if we have a mini server (in other words, an Intel NUC), an old computer, or a laptop to be used as the machine for following along with this book.
Next, we will look at how to prepare a virtual machine in your installation, in case you are considering following this book with your current main laptop (or workstation) but you still want to keep a separate machine to work with.
Preparation for a virtual server installation
A virtual server works as if having some virtualization software that emulates a real machine in your current system. In a Linux workstation, installing virt-manager will add all the under-the-hood components required to run (for your information, these components are KVM, Libvirt, Qemu, and virsh, among others). Other no-cost virtualization software recommended for Windows or macOS systems includes Oracle VirtualBox and VMware Workstation Player.
The examples in this section will be executed using virt-manager, but are easily applicable to any other virtualization software, whether in a laptop or in the largest deployments.
The preliminary steps have been described previously and require obtaining the Red Hat Enterprise Linux ISO image, which, in this case, will be rhel-baseos-9.0-beta-0-x86_64-dvd.iso. Once downloaded and, if possible, having checked its integrity (as mentioned in the last tip