Technical Reviewers: Many of my students and colleagues Editors: FirstEditing.com and Zainab Ghori Cover Design: Nid n Nad Graphics Printing Inc. Printers and Distributors: IngramSpark Inc. Copyright © 2020 Asghar Ghori All rights reserved. No portion of this book may be stored in a retrieval system, transmitted, or reproduced in any form, including but not limited to photocopying or other recording, without the express written consent of the author. Printed in the USA, Canada, UK, France, Germany, Italy, Spain, and Australia. ISBN: 978-1-7750621-2-7 ISBN: 978-1-7750621-3-4 (e-book) Library of Congress Control Number: 2019920023 To order in bulk at special quantity discounts for sales promotions or for use in training programs, please contact the author at asghar_ghori2002@yahoo.com The following are registered trademarks in the U.S. and other countries: Red Hat® is a registered trademark of Red Hat, Inc. RHCSA® is a registered trademark of Red Hat, Inc. Linux® is a registered trademark of Linus Torvalds. Oracle® is a registered trademark of Oracle Corporation, Inc. UNIX® is a registered trademark of The Open Group. Microsoft® and Windows® are US registered trademarks of Microsoft Corporation. Intel® is the trademark or registered trademark of Intel Corporation or its subsidiaries. All other trademarks, registered trademarks, or logos used in this book are the property of their respective owners. The author has made his best efforts to prepare this book. The contents are based on Red Hat® Enterprise Linux® version 8. The author makes no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accepts no liability whatsoever including but not limited to merchantability, fitness for any particular purpose, or any losses or damages of any kind caused or allegedly caused directly or indirectly from this material. This book is not a replacement for the official RHCSA training courses offered by Red Hat, Inc. However, it may be used to prepare for the Red Hat Certified System Administrator (RHCSA) exam, EX200, based on Red Hat® Enterprise Linux® version 8. Neither author nor publisher warrants that use of this publication will ensure passing the relevant exams or that the information contained herein is endorsed by Red Hat, Inc. Preface Red Hat® had revised their EX200 exam for the RHCSA certification soon after the release of Red Hat® Enterprise Linux® version 8 in April 2019. As usual, these exams are performance-based and present scenarios that are to be accomplished on live systems within a stipulated time. This book is written to provide necessary coverage of theoretical and practical information to help you pass the exam. Furthermore, this book may be used for classroom trainings and as a deskside reference. Keeping in mind the hands-on nature of the exam, I have included a multitude of step-by-step exercises and Do-It- Yourself (DIY) challenge labs throughout the book. Chapter 01 details the infrastructure that is needed to practice the procedures and perform the labs. It also outlines how to obtain a copy of RHEL 8. I suggest you study the material presented in each chapter thoroughly before proceeding to the relevant hands- on exercise(s). I have provided several review questions with answers at the end of each chapter. Take the quiz and then attempt the DIY challenge labs offered thereafter. I have not furnished solutions to these labs intentionally, as I am confident that the knowledge and skills you will have gained by that time will be sufficient to accomplish the labs on your own; and, in essence, this is what I want you to eventually get at. Once you have read and understood the material, performed exercises, completed review questions, and accomplished DIY challenge labs, take time to attempt the sample RHCSA exams provided in appendices. While performing exercises and labs, if a command does not produce the published result, I advise that you check the message the command has generated and consult relevant log files. Minor issues, such as a wrong path or typo, prevent commands from executing correctly. Sometimes, syntax errors in command constructs could result in execution failures. You might have to make modifications to your command in order to run it as expected. RHEL manual pages prove helpful in comprehending commands and their syntaxes. There are four areas I suggest you focus on in order to develop expertise with RHEL, as well as to prepare for the exams: 1) grasping concepts; 2) mastering implementation procedures, exercises, and labs; 3) learning commands, understanding configuration files, and knowing service processes; and 4) being able to troubleshoot and resolve problems. An excellent knowledge of commands and key options, and the files they update should also be developed along with what processes handle which services, and so on. This will help you obtain a greater overall understanding of what exactly happens in the background when a command is executed. Debugging becomes easier when concepts are clear and working knowledge is solid. I maintain www.nixeducation.com where I add errata, additional certification information, helpful videos on Linux concepts and administration topics, and links to other useful resources. I encourage you to visit this website. To conclude, I would like to request for your constructive feedback sent to my personal email asghar_ghori2002@yahoo.com about any grammatical or technical errors or mistakes in the book, as well as any additional suggestions. Try to be as specific as possible in your description. Improvement is a continuous process, and I believe your feedback will help me continue to deliver quality books to you. Good luck in your endeavors. Asghar Ghori / January 2020 / Toronto, Canada Acknowledgments I am grateful to God who enabled me to write this book successfully. I would like to acknowledge the valuable feedback my students, friends, and colleagues provided on my previous RHCSA and RHCE guides. I am thankful to them for making this book better in all respects. I recognize the constructive and positive feedback I had received from the readers of my previous publications. I have used their comments toward the improvement of this edition. I would like to express my special thanks to my wife, daughters, and sons, who endured my mental absence while writing this book. I could not have accomplished this project without their continuous support. Lastly, I would like to offer my very special tributes to my deceased parents and sisters. Asghar Ghori About the Author Asghar Ghori is a seasoned Linux/Cloud/DevOps consultant, trainer, and author. As a consultant, his experience ranges from deployment, support, and administration to solution architecture, design, and consulting; as a trainer, he has designed and delivered numerous training programs; and as a published author, he has eight books on UNIX and Linux (Red Hat Enterprise Linux and CompTIA Linux+) to his credit. Asghar holds a BS in Engineering. He is RHCE, RHCSA, HP CSA, HP CSE, Oracle SCSA, IBM Certified Specialist for AIX, and CNE, with ITIL and PMP certifications. He is AWS CLP, SA, DA, and SysOps Administrator, as well as Azure Solution Architect Expert. Asghar Ghori lives in a small town near Toronto, Ontario, Canada with his wife and children, and can be reached via email asghar_ghori2002@yahoo.com or LinkedIn. Other publications of Asghar are: 1. CompTIA Linux+/LPIC-1: Training and Exam Preparation Guide (Exam Codes: LX0-103/101-400 and LX0-104/102-400) (ISBN: 978-1775062103), published 2017 2. RHCSA & RHCE Red Hat Enterprise Linux 7: Training and Exam Preparation Guide (EX200 and EX300) (ISBN: 978-1495148200) (RHEL version 7), published 2015 3. Red Hat Certified System Administrator & Engineer: Training Guide and a Quick Deskside Reference (ISBN: 978-1467549400) (RHEL version 6), published 2012 4. Red Hat Certified Technician & Engineer (RHCT and RHCE) Training Guide and Administrator’s Reference (ISBN: 978-1615844302) (RHEL version 5), published 2009 5. HP-UX: HP Certified Systems Administrator, Exam HP0-A01, Training Guide and Administrator’s Reference (ISBN: 978-1606436547) (HP-UX 11iv3), published 2008 6. HP Certified Systems Administrator, Exam HP0-095, Training Guide and Administrator’s Reference (ISBN: 978-1424342310) (HP-UX 11iv2 and 11iv3), published 2007 7. Certified System Administrator for HP-UX: Study Guide and Administrator’s Reference (ISBN: 978- 1419645938) (HP-UX 11iv1), published 2006 Conventions Used in this Book The following typographic and other conventions are used in this book: Book Antiqua Italic 10 pt. is used in text paragraphs to introduce new terms. For example: “Red Hat renamed the Red Hat Linux operating system series Red Hat Enterprise Linux (RHEL) in 2003.” Times Roman Italic 10 pt. is used in text paragraphs to highlight names of files, directories, commands, daemons, users, groups, hosts, domains, and URLs. This font also highlights file and directory paths. For example: “To go directly from /etc to a subdirectory dir1 under user1 ’s home directory, create dir1 , as . . . .” Times New Roman 9 pt. is used to segregate command output, script/file contents, and information expected to be entered in configuration files from the surrounding text. It is also used in tables, index, and side notes. Times Roman Bold 10 pt. is used to highlight commands and command line arguments that the user is expected to type and execute at the command prompt. For example: [user1@server1 ~]$ ls -lt There are two white spaces between parts of a typed command for the sake of clarity in text. There are hundreds of screenshots that show commands and output. They are images taken directly from the Linux terminal screen. All headings and sub-headings are in California FB font, and are bolded. Ctrl+x key sequence implies that you hold down the Ctrl key and then press the other key. Courier New font is used to highlight such combinations. This font is also used to identify keystrokes, such as Enter and Esc. . . . . . . . . Dotted lines represent truncated command output. About the RHCSA Exam (EX200) on RHEL 8 The Red Hat Certified System Administrator (RHCSA) certification exam is a performance-based hands-on exam designed for IT professionals. This exam is presented in electronic format on a live desktop computer running Red Hat Enterprise Linux 8. This desktop computer will have two RHEL 8-based virtual machines to accomplish the exam tasks. During the exam, the candidates will not have access to the Internet, or printed or electronic material except for what comes standard with RHEL 8. The official exam objectives (57 in total as of January 8, 2020) are listed at http://www.redhat.com/training/courses/ex200/examobjectiv e . Visit the URL for up-to-date and in-depth information. The exam objectives are covered in detail in the chapters throughout the book. An enumerated list of exam objectives is presented below along with the chapter number where the objective is discussed. Understand and Use Essential Tools 1. Access a shell prompt and issue commands with correct syntax (chapter 2) 2. Use input-output redirection (>, >>, |, 2>, etc) (chapter 7) 3. Use grep and regular expressions to analyze text (chapter 7) 4. Access remote systems using ssh (chapter 19) 5. Log in and switch users in multi-user targets (chapter 6) 6. Archive, compress, unpack, and uncompress files using tar, star, gzip, and bzip2 (chapter 3) 7. Create and edit text files (chapter 3) 8. Create, delete, copy, and move files and directories (chapter 3) 9. Create hard and soft links (chapter 3) 10. List, set, and change standard ugo/rwx permissions (chapter 4) 11. Locate, read, and use system documentation including man, info, and files in /usr/share/doc (chapter 2) Operate Running Systems 12. Boot, reboot, and shut down a system normally (chapter 12) 13. Boot systems into different targets manually (chapter 12) 14. Interrupt the boot process in order to gain access to a system (chapter 11) 15. Identify CPU/memory intensive processes and kill processes (chapter 8) 16. Adjust process scheduling (chapter 8) 17. Manage tuning profiles (chapter 12) 18. Locate and interpret system log files and journals (chapter 12) 19. Preserve system journals (chapter 12) 20. Start, stop, and check the status of network services (chapter 12) 21. Securely transfer files between systems (chapter 19) Configure Local Storage 22. List, create, and delete partitions on MBR and GPT disks (chapter 13) 23. Create and remove physical volumes (chapter 14) 24. Assign physical volumes to volume groups (chapter 14) 25. Create and delete logical volumes (chapter 14) 26. Configure systems to mount file systems at boot by Universally Unique ID (UUID) or label (chapter 15) 27. Add new partitions and logical volumes, and swap to a system non-destructively (chapters 14 and 15) Create and Configure File Systems 28. Create, mount, unmount, and use vfat, ext4, and xfs file systems (chapter 15) 29. Mount and unmount network file systems using NFS (chapter 16) 30. Extend existing logical volumes (chapters 14 and 15) 31. Create and configure set-GID directories for collaboration (chapter 4) 32. Configure disk compression (chapter 13) 33. Manage layered storage (chapter 14) 34. Diagnose and correct file permission problems (chapter 4) Deploy, Configure, and Maintain Systems 35. Schedule tasks using at and cron (chapter 8) 36. Start and stop services and configure services to start automatically at boot (chapter 12) 37. Configure systems to boot into a specific target automatically (chapter 12) 38. Configure time service clients (chapter 18) 39. Install and update software packages from Red Hat Network, a remote repository, or from the local file system (chapter 9 and 10) 40. Work with package module streams (chapter 10) 41. Modify the system bootloader (chapter 11) Manage Basic Networking 42. Configure IPv4 and IPv6 addresses (chapter 17) 43. Configure hostname resolution (chapter 18) 44. Configure network services to start automatically at boot (chapter 12) 45. Restrict network access using firewall-cmd/firewall (chapter 20) Manage Users and Groups 46. Create, delete, and modify local user accounts (chapter 5) 47. Change passwords and adjust password aging for local user accounts (chapter 5 and 6) 48. Create, delete, and modify local groups and group memberships (chapter 6) 49. Configure superuser access (chapter 6) Manage Security 50. Configure firewall settings using firewall-cmd/firewalld (chapter 20) 51. Create and use file access control lists (chapter 4) 52. Configure key-based authentication for SSH (chapter 19) 53. Set enforcing and permissive modes for SELinux (chapter 21) 54. List and identify SELinux file and process context (chapter 21) 55. Restore default file contexts (chapter 21) 56. Use Boolean settings to modify system SELinux settings (chapter 21) 57. Diagnose and address routine SELinux policy violations (chapter 21) Taking the Exam 1. Save time wherever possible, as time is of the essence during the exam 2. Make certain that any changes you make must survive system reboots 3. Use any text editor you feel comfortable with to modify text configuration files 4. Exam tasks are split into two groups and each group must be performed in its own assigned virtual machine 5. Inform the proctor right away if you encounter an issue with your exam system or the virtual machines 6. Exam is administered with no access to the Internet, electronic devices, or written material 7. Read each exam task carefully and understand it thoroughly before attempting it Exam Fees and Registration Procedure The fee for the RHCSA exam is US$400 (plus any applicable taxes), or equivalent in local currencies. To register, visit http://www.redhat.com/training/courses/ex200/examobjectiv e , select your location and an exam format, and click Get Started to continue through the registration process. The RHCSA exam lasts for 2.5 hours. About this Book This book covers four major learning objectives: 1) a self- study guide for exam aspirants who intend to pass the RHCSA 8 exam, 2) an in-class training guide for college students, 3) an on-the-job reference for administrators, programmers, and managers, and 4) an easy-to-understand guide for novice and non-RHEL administrators who wish to learn RHEL from scratch. This book has 21 chapters that are organized logically, keeping in mind the four learning objectives mentioned above. It covers the topics on local RHEL 8 installation; initial interaction with the system and basic commands; compression and archiving; file editing and manipulation; standard and special permissions; file searching and access controls; user monitoring and authentication files; users, groups, and password aging; bash shell features and startup files; processes and task scheduling; basic and advanced software administration techniques; system boot process and bootloader; kernel management and system initialization; logging and system tuning; basic and advanced storage management tools and solutions; local and remote file systems and swap regions; network device and connection configuration; time synchronization and hostname resolution; the secure shell service; and firewall and SELinux controls. Each chapter highlights the major topics and relevant exam objectives at the beginning, and ends with review questions & answers and Do-It-Yourself challenge labs. Throughout the book, figures, tables, screen shots, examples, and exam tips have been furnished to support explanation and exam preparation. This book includes four sample exams for RHCSA, which are expected to be done using the knowledge and skills attained from reading the material and practicing the exercises and challenge labs. The labs and the sample exams include references to relevant topics and/or exercises. TABLE OF CONTENTS Preface Acknowledgments About the Author Conventions Used in this Book About the RHCSA Exam (EX200) on RHEL 8 About this Book 01. Local Installation A Quick Look at Linux Development Linux History in a Nutshell Linux from Red Hat Lab Infrastructure for Practice What is Needed for the Lab? The RHEL Installer Program Where Do Installation Logs Go? Virtual Console Screens Exercise 1-1: Download and Install VirtualBox Software, and Create a Virtual Machine Downloading and Installing VirtualBox Creating a Virtual Machine Exercise 1-2: Download and Install RHEL 8 Downloading RHEL 8 ISO Image Attaching RHEL 8 ISO Image to the Virtual Machine Launching the Installer Adding Support for Keyboards and Languages Configuring Time & Date Choosing an Installation Source Selecting Software to be Installed Configuring Installation Destination Configuring Network and Hostname Beginning Installation Setting root Password and Creating a User Account Concluding Installation Changing Default Boot Order Performing Post-Installation Tasks Logging In and Out Logging In for the First Time Logging Out Chapter Summary Check Your Understanding Answers to Check Your Understanding Do-It-Yourself Challenge Labs Lab 1-1: Build RHEL8-VM2 (server2) 02. Initial Interaction with the System Linux Graphical Environment Display/Login Manager Desktop Environment Linux Directory Structure and File Systems Top-Level Directories File System Categories The Root File System (/), Disk-Based The Boot File System (/boot) – Disk-Based The Home Directory (/home) The Optional Directory (/opt) The UNIX System Resources Directory (/usr) The Variable Directory (/var)