Red Hat Enterprise Linux 9.0 RH124 Student Guide PDF

Document Details

Uploaded by Deleted User

2022

Ashish Lingayat,Bernardo Gargallo,Ed Parenti,Jacob Pelchat,Mike Kelly,Morgan Weetman,Patrick Gomez

Tags

linux system administration red hat enterprise linux computer science

Summary

This Red Hat System Administration I student guide covers Red Hat Enterprise Linux 9.0. The guide provides exercises and quizzes to practice skills, and the guide explains processes, files, and access control using command lines and the desktop.

Full Transcript

Student Workbook (ROLE) Red Hat Enterprise Linux 9.0 RH124 Red Hat System Administration I Edition 2 RH124-RHEL9.0-en-2-20220609 Copyright ©2022 Red Hat, Inc. RH124-RHEL9.0-en-2-20220609 Copyright ©2022 Red Hat, Inc. Red Hat...

Student Workbook (ROLE) Red Hat Enterprise Linux 9.0 RH124 Red Hat System Administration I Edition 2 RH124-RHEL9.0-en-2-20220609 Copyright ©2022 Red Hat, Inc. RH124-RHEL9.0-en-2-20220609 Copyright ©2022 Red Hat, Inc. Red Hat System Administration I Red Hat Enterprise Linux 9.0 RH124 Red Hat System Administration I Edition 2 20220609 Publication date 20220609 Authors: Ashish Lingayat, Bernardo Gargallo, Ed Parenti, Jacob Pelchat, Mike Kelly, Morgan Weetman, Patrick Gomez Course Architect: Philip Sweany DevOps Engineer: Artur Glogowski Editor: Julian Cable Copyright © 2022 Red Hat, Inc. The contents of this course and all its modules and related materials, including handouts to audience members, are Copyright © 2022 Red Hat, Inc. No part of this publication may be stored in a retrieval system, transmitted or reproduced in any way, including, but not limited to, photocopy, photograph, magnetic, electronic or other record, without the prior written permission of Red Hat, Inc. This instructional program, including all material provided herein, is supplied without any guarantees from Red Hat, Inc. Red Hat, Inc. assumes no liability for damages or legal action arising from the use or misuse of contents or details contained herein. If you believe Red Hat training materials are being used, copied, or otherwise improperly distributed, please send email to [email protected] or phone toll-free (USA) +1 (866) 626-2994 or +1 (919) 754-3700. Red Hat, Red Hat Enterprise Linux, the Red Hat logo, JBoss, OpenShift, Fedora, Hibernate, Ansible, CloudForms, RHCA, RHCE, RHCSA, Ceph, and Gluster are trademarks or registered trademarks of Red Hat, Inc. or its subsidiaries in the United States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other countries. Java® is a registered trademark of Oracle American, Inc. and/or its affiliates. XFS® is a registered trademark of Hewlett Packard Enterprise Development LP 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 a 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 the Square O Design, together or apart, are trademarks or registered trademarks of OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. Red Hat, Inc. is not affiliated with, endorsed by, or sponsored by the OpenStack Foundation or the OpenStack community. All other trademarks are the property of their respective owners. Contributors: Adarsh Krishnan, David Sacco, Hemant Chauhan, Roberto Velazquez, Sajith Eyamkuzhy, Samik Sanyal, Yuvaraj Balaraju Document Conventions xi.............................................................................................................................. xi Introduction xiii Red Hat System Administration I............................................................................... xiii Orientation to the Classroom Environment................................................................. xiv Performing Lab Exercises....................................................................................... xviii 1. Get Started with Red Hat Enterprise Linux 1 What Is Linux?.......................................................................................................... 2 Quiz: Get Started with Red Hat Enterprise Linux.......................................................... 10 Summary................................................................................................................ 12 2. Access the Command Line 13 Access the Command Line....................................................................................... 14 Quiz: Access the Command Line............................................................................... 19 Access the Command Line with the Desktop.............................................................. 23 Guided Exercise: Access the Command Line with the Desktop...................................... 28 Execute Commands with the Bash Shell.................................................................... 30 Quiz: Execute Commands with the Bash Shell............................................................ 36 Lab: Access the Command Line............................................................................... 40 Summary............................................................................................................... 46 3. Manage Files from the Command Line 47 Describe Linux File System Hierarchy Concepts.......................................................... 48 Quiz: Describe Linux File System Hierarchy Concepts.................................................. 50 Specify Files by Name............................................................................................. 54 Quiz: Specify Files by Name..................................................................................... 59 Manage Files with Command-line Tools..................................................................... 63 Guided Exercise: Manage Files with Command-line Tools............................................. 68 Make Links Between Files........................................................................................ 72 Guided Exercise: Make Links Between Files................................................................ 76 Match File Names with Shell Expansions.................................................................... 78 Quiz: Match File Names with Shell Expansions............................................................ 83 Lab: Manage Files from the Command Line............................................................... 87 Summary............................................................................................................... 97 4. Get Help in Red Hat Enterprise Linux 99 Read Manual Pages............................................................................................... 100 Guided Exercise: Read Manual Pages....................................................................... 104 Lab: Get Help in Red Hat Enterprise Linux................................................................ 108 Summary............................................................................................................... 115 5. Create, View, and Edit Text Files 117 Redirect Output to a File or Program........................................................................ 118 Quiz: Redirect Output to a File or Program................................................................ 124 Edit Text Files from the Shell Prompt........................................................................ 128 Guided Exercise: Edit Text Files from the Shell Prompt................................................ 132 Change the Shell Environment................................................................................ 134 Guided Exercise: Change the Shell Environment......................................................... 141 Lab: Create, View, and Edit Text Files....................................................................... 144 Summary.............................................................................................................. 152 6. Manage Local Users and Groups 153 Describe User and Group Concepts......................................................................... 154 Quiz: Describe User and Group Concepts................................................................. 157 Gain Superuser Access............................................................................................ 161 Guided Exercise: Gain Superuser Access.................................................................. 166 RH124-RHEL9.0-en-2-20220609 vii Manage Local User Accounts................................................................................... 171 Guided Exercise: Manage Local User Accounts.......................................................... 174 Manage Local Group Accounts................................................................................ 177 Guided Exercise: Manage Local Group Accounts....................................................... 180 Manage User Passwords......................................................................................... 183 Guided Exercise: Manage User Passwords................................................................. 187 Lab: Manage Local Users and Groups....................................................................... 191 Summary.............................................................................................................. 197 7. Control Access to Files 199 Interpret Linux File System Permissions................................................................... 200 Quiz: Interpret Linux File System Permissions........................................................... 204 Manage File System Permissions from the Command Line......................................... 208 Guided Exercise: Manage File System Permissions from the Command Line................... 212 Manage Default Permissions and File Access............................................................. 215 Guided Exercise: Manage Default Permissions and File Access.................................... 220 Lab: Control Access to Files................................................................................... 224 Summary............................................................................................................. 230 8. Monitor and Manage Linux Processes 231 Process States and Lifecycle.................................................................................. 232 Quiz: Process States and Lifecycle.......................................................................... 237 Control Jobs........................................................................................................ 239 Guided Exercise: Control Jobs................................................................................ 242 Kill Processes........................................................................................................ 247 Guided Exercise: Kill Processes............................................................................... 253 Monitor Process Activity........................................................................................ 257 Guided Exercise: Monitor Process Activity................................................................. 261 Lab: Monitor and Manage Linux Processes............................................................... 266 Summary............................................................................................................. 277 9. Control Services and Daemons 279 Identify Automatically Started System Processes...................................................... 280 Guided Exercise: Identify Automatically Started System Processes.............................. 285 Control System Services........................................................................................ 289 Guided Exercise: Control System Services................................................................ 293 Lab: Control Services and Daemons........................................................................ 297 Summary.............................................................................................................. 301 10. Configure and Secure SSH 303 Access the Remote Command Line with SSH........................................................... 304 Guided Exercise: Access the Remote Command Line................................................ 307 Configure SSH Key-based Authentication.................................................................. 311 Guided Exercise: Configure SSH Key-based Authentication......................................... 317 Customize OpenSSH Service Configuration.............................................................. 323 Guided Exercise: Customize OpenSSH Service Configuration..................................... 325 Lab: Configure and Secure SSH............................................................................... 331 Summary............................................................................................................. 338 11. Analyze and Store Logs 339 Describe System Log Architecture.......................................................................... 340 Quiz: Describe System Log Architecture.................................................................. 342 Review Syslog Files............................................................................................... 346 Guided Exercise: Review Syslog Files........................................................................ 351 Review System Journal Entries............................................................................... 353 Guided Exercise: Review System Journal Entries....................................................... 358 Preserve the System Journal.................................................................................. 361 viii RH124-RHEL9.0-en-2-20220609 Guided Exercise: Preserve the System Journal......................................................... 364 Maintain Accurate Time......................................................................................... 367 Guided Exercise: Maintain Accurate Time.................................................................. 371 Lab: Analyze and Store Logs.................................................................................. 375 Summary............................................................................................................. 380 12. Manage Networking 381 Describe Networking Concepts............................................................................... 382 Quiz: Describe Networking Concepts...................................................................... 395 Validate Network Configuration.............................................................................. 399 Guided Exercise: Validate Network Configuration...................................................... 405 Configure Networking from the Command Line........................................................ 408 Guided Exercise: Configure Networking from the Command Line................................. 415 Edit Network Configuration Files.............................................................................. 421 Guided Exercise: Edit Network Configuration Files..................................................... 425 Configure Hostnames and Name Resolution............................................................. 429 Guided Exercise: Configure Hostnames and Name Resolution..................................... 432 Lab: Manage Networking....................................................................................... 436 Summary.............................................................................................................. 441 13. Archive and Transfer Files 443 Manage Compressed tar Archives........................................................................... 444 Guided Exercise: Manage Compressed tar Archives.................................................. 449 Transfer Files Between Systems Securely.................................................................. 451 Guided Exercise: Transfer Files Between Systems Securely......................................... 454 Synchronize Files Between Systems Securely........................................................... 457 Guided Exercise: Synchronize Files Between Systems Securely................................... 460 Lab: Archive and Transfer Files............................................................................... 463 Summary............................................................................................................. 468 14. Install and Update Software Packages 469 Register Systems for Red Hat Support..................................................................... 470 Quiz: Register Systems for Red Hat Support............................................................. 473 Explain and Investigate RPM Software Packages....................................................... 475 Guided Exercise: Explain and Investigate RPM Software Packages............................... 479 Install and Update Software Packages with DNF....................................................... 483 Guided Exercise: Install and Update Software Packages with DNF................................ 492 Enable DNF Software Repositories.......................................................................... 497 Guided Exercise: Enable DNF Software Repositories................................................. 500 Lab: Install and Update Software Packages.............................................................. 504 Summary.............................................................................................................. 510 15. Access Linux File Systems 511 Identify File Systems and Devices............................................................................ 512 Quiz: Identify File Systems and Devices.................................................................... 516 Mount and Unmount File Systems............................................................................ 518 Guided Exercise: Mount and Unmount File Systems.................................................... 521 Locate Files on the System.................................................................................... 524 Guided Exercise: Locate Files on the System............................................................. 531 Lab: Access Linux File Systems............................................................................... 534 Summary............................................................................................................. 539 16. Analyze Servers and Get Support 541 Analyze and Manage Remote Servers...................................................................... 542 Guided Exercise: Analyze and Manage Remote Servers.............................................. 554 Get Help From Red Hat Customer Portal.................................................................. 558 Guided Exercise: Get Help From Red Hat Customer Portal.......................................... 563 RH124-RHEL9.0-en-2-20220609 ix Detect and Resolve Issues with Red Hat Insights....................................................... 565 Quiz: Detect and Resolve Issues with Red Hat Insights................................................ 572 Summary............................................................................................................. 574 17. Comprehensive Review 575 Comprehensive Review.......................................................................................... 576 Lab: Manage Files from the Command Line............................................................. 580 Lab: Manage Users and Groups, Permissions, and Processes...................................... 587 Lab: Configure and Manage a Server....................................................................... 593 Lab: Manage Networks......................................................................................... 600 Lab: Mount File Systems and Find Files................................................................... 606 x RH124-RHEL9.0-en-2-20220609 Document Conventions This section describes various conventions and practices used throughout all Red Hat Training courses. Admonitions Red Hat Training courses use the following admonitions: References These describe where to find external documentation relevant to a subject. Note These are tips, shortcuts, or alternative approaches to the task at hand. Ignoring a note should have no negative consequences, but you might miss out on something that makes your life easier. Important These provide details of information that is easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply. Ignoring these admonitions will not cause data loss, but may cause irritation and frustration. Warning These should not be ignored. Ignoring these admonitions will most likely cause data loss. Inclusive Language Red Hat Training is currently reviewing its use of language in various areas to help remove any potentially offensive terms. This is an ongoing process and requires alignment with the products and services covered in Red Hat Training courses. Red Hat appreciates your patience during this process. RH124-RHEL9.0-en-2-20220609 xi xii RH124-RHEL9.0-en-2-20220609 Introduction Red Hat System Administration I Red Hat System Administration I (RH124) is designed for IT professionals without previous Linux system administration experience. The course provides students with Linux administration "survival skills" by focusing on core administration tasks. Red Hat System Administration I also provides a foundation for students who plan to become full-time Linux system administrators by introducing key command-line concepts and enterprise- level tools. These concepts are further developed in the follow-on course, Red Hat System Administration II (RH134). Course Gain sufficient skill to perform core system Objectives administration tasks on Red Hat Enterprise Linux. Build foundational skills that an RHCSA- certified Red Hat Enterprise Linux system administrator needs. Audience IT professionals across a broad range of disciplines who need to perform essential Linux administration tasks, including installation, establishing network connectivity, managing physical storage, and basic security administration. Prerequisites This course has no formal prerequisites; however, previous system administration experience on other operating systems is beneficial. RH124-RHEL9.0-en-2-20220609 xiii Introduction Orientation to the Classroom Environment Figure 0.1: Classroom environment In this course, the main computer system for hands-on learning activities is workstation. Students also use two other machines for these activities: servera and serverb. All three systems are in the lab.example.com DNS domain. All student computer systems have a standard user account, student, which has the password student. The root password on all student systems is redhat. Classroom Machines Machine name IP addresses Role bastion.lab.example.com 172.25.250.254 Gateway system to connect student private network to classroom server (must always be running) workstation.lab.example.com 172.25.250.9 Graphical workstation for system administration servera.lab.example.com 172.25.250.10 Managed server "A" serverb.lab.example.com 172.25.250.11 Managed server "B" The primary function of bastion is to act as a router between the network that connects the student machines and the classroom network. If bastion is down, then other student machines can access only systems on the individual student network. Several systems in the classroom provide supporting services. Two servers, content.example.com and materials.example.com, are sources for software and lab xiv RH124-RHEL9.0-en-2-20220609 Introduction materials in hands-on activities. Information about how to use these servers is provided in the instructions for those activities. These activities are provided by the workstation virtual machine. Both classroom and bastion must always be running for proper use of the lab environment. Note When logging on to servera or serverb, you might see a message about activating cockpit. You can ignore the message. [student@workstation ~]$ ssh student@serverb Warning: Permanently added 'serverb,172.25.250.11' (ECDSA) to the list of known hosts. Activate the web console with: systemctl enable --now cockpit.socket [student@serverb ~]$ Controlling Your Systems You are assigned remote computers in a Red Hat Online Learning (ROLE) classroom. Self- paced courses are accessed through a web application that is hosted at rol.redhat.com [http:// rol.redhat.com]. Log in to this site with your Red Hat Customer Portal user credentials. Controlling the Virtual Machines The virtual machines in your classroom environment are controlled through web page interface controls. The state of each classroom virtual machine is displayed on the Lab Environment tab. Figure 0.2: An example course Lab Environment management page RH124-RHEL9.0-en-2-20220609 xv Introduction Machine States Virtual machine Description state building The virtual machine is being created. active The virtual machine is running and available. If it just started, it still might be starting services. stopped The virtual machine is completely shut down. On starting, the virtual machine boots into the same state it was in before shutdown. The disk state is preserved. Classroom Actions Button or action Description CREATE Create the ROLE classroom. Creates and starts all the virtual machines needed for this classroom. Creation can take several minutes to complete. CREATING The ROLE classroom virtual machines are being created. Creates and starts all the virtual machines that are needed for this classroom. Creation can take several minutes to complete. DELETE Delete the ROLE classroom. Destroys all virtual machines in the classroom. All saved work on those systems' disks is lost. START Start all virtual machines in the classroom. STARTING All virtual machines in the classroom are starting. STOP Stop all virtual machines in the classroom. Machine Actions Button or action Description OPEN CONSOLE Connect to the system console of the virtual machine in a new browser tab. You can log in directly to the virtual machine and run commands, when required. Normally, log in to the workstation virtual machine only, and from there, use ssh to connect to the other virtual machines. ACTION > Start Start (power on) the virtual machine. ACTION > Shutdown Gracefully shut down the virtual machine, preserving disk contents. ACTION > Power Off Forcefully shut down the virtual machine, while still preserving disk contents. This is equivalent to removing the power from a physical machine. ACTION > Reset Forcefully shut down the virtual machine and reset associated storage to its initial state. All saved work on that system's disks is lost. xvi RH124-RHEL9.0-en-2-20220609 Introduction At the start of an exercise, if instructed to reset a single virtual machine node, click ACTION > Reset for only that specific virtual machine. At the start of an exercise, if instructed to reset all virtual machines, click ACTION > Reset on every virtual machine in the list. If you want to return the classroom environment to its original state at the start of the course, then click DELETE to remove the entire classroom environment. After the lab has been deleted, then click CREATE to provision a new set of classroom systems. Warning The DELETE operation cannot be undone. All completed work in the classroom environment is lost. The Auto-stop and Auto-destroy Timers The Red Hat Online Learning enrollment entitles you to a set allotment of computer time. To help conserve your allotted time, the ROLE classroom uses timers, which shut down or delete the classroom environment when the appropriate timer expires. To adjust the timers, locate the two + buttons at the bottom of the course management page. Click the auto-stop + button to add another hour to the auto-stop timer. Click the auto-destroy + button to add another day to the auto-destroy timer. Auto-stop has a maximum of 11 hours, and auto-destroy has a maximum of 14 days. Be careful to keep the timers set while you are working, so that your environment is not unexpectedly shut down. Be careful not to set the timers unnecessarily high, which could waste your subscription time allotment. RH124-RHEL9.0-en-2-20220609 xvii Introduction Performing Lab Exercises You might see the following lab activity types in this course: A guided exercise is a hands-on practice exercise that follows a presentation section. It walks you through a procedure to perform, step by step. A quiz is typically used when checking knowledge-based learning, or when a hands-on activity is impractical for some other reason. An end-of-chapter lab is a gradable hands-on activity to help you to check your learning. You work through a set of high-level steps, based on the guided exercises in that chapter, but the steps do not walk you through every command. A solution is provided with a step-by-step walk- through. A comprehensive review lab is used at the end of the course. It is also a gradable hands-on activity, and might cover content from the entire course. You work through a specification of what to accomplish in the activity, without receiving the specific steps to do so. Again, a solution is provided with a step-by-step walk-through that meets the specification. To prepare your lab environment at the start of each hands-on activity, run the lab start command with a specified activity name from the activity's instructions. Likewise, at the end of each hands-on activity, run the lab finish command with that same activity name to clean up after the activity. Each hands-on activity has a unique name within a course. The syntax for running an exercise script is as follows: [student@workstation ~]$ lab action exercise The action is a choice of start, grade, or finish. All exercises support start and finish. Only end-of-chapter labs and comprehensive review labs support grade. start The start action verifies the required resources to begin an exercise. It might include configuring settings, creating resources, checking prerequisite services, and verifying necessary outcomes from previous exercises. You can take an exercise at any time, even without taking preceding exercises. grade For gradable activities, the grade action directs the lab command to evaluate your work, and shows a list of grading criteria with a PASS or FAIL status for each. To achieve a PASS status for all criteria, fix the failures and rerun the grade action. finish The finish action cleans up resources that were configured during the exercise. You can take an exercise as many times as you want. The lab command supports tab completion. For example, to list all exercises that you can start, enter lab start and then press the Tab key twice. xviii RH124-RHEL9.0-en-2-20220609 Chapter 1 Get Started with Red Hat Enterprise Linux Goal Describe and define open source, Linux, Linux distributions, and Red Hat Enterprise Linux. Objectives Define and explain the purpose of Linux, open source, Linux distributions, and Red Hat Enterprise Linux. Sections What Is Linux? (and Quiz) RH124-RHEL9.0-en-2-20220609 1 Chapter 1 | Get Started with Red Hat Enterprise Linux What Is Linux? Objectives Define and explain the purpose of Linux, open source, Linux distributions, and Red Hat Enterprise Linux. Why Should You Learn about Linux? Linux is a critical technology for IT professionals to understand. Linux is in widespread use, worldwide. Internet users interact with Linux application and web server systems daily, by browsing the World Wide Web and using e-commerce sites to buy and sell products. Linux is in use for much more than the internet. Linux manages point-of-sale systems and the world's stock markets, powers smart TVs and in-flight entertainment systems, and runs most of the top 500 supercomputers in the world. Linux provides the core technologies that power the cloud revolution and the tools to build the latest generations of container-based microservices applications, software-based storage technologies, and big data solutions. In the modern data center, Linux and Microsoft Windows are the predominant operating systems. Linux use continues to expand in enterprise, cloud, and device spaces. Due to its widespread adoption, you have many reasons to learn Linux: A Windows user needs to interoperate with Linux systems and applications. In application development, Linux commonly hosts the application and its runtime. In cloud computing, both private and public cloud instances use Linux as the operating system. Mobile applications and Internet of Things (IoT) devices commonly run on Linux. When looking for new IT career opportunities, Linux skills are in high demand. What Makes Linux Great? If someone asks you "What makes Linux great?", then you have many answers to pick from: Linux is open source software. Being open source means that you can see all of how a program or system works. You can also experiment with changes and share them freely for others to use. The open source model means that improvements are easier to make, enabling faster innovation. Linux provides a command-line interface (CLI) for easy access and powerful scripting. Linux is built around a basic design philosophy that users can perform all administration tasks from the CLI. It enables easier automation, deployment, and provisioning, and simplifies both local and remote system administration. Unlike many other operating systems, these capabilities were in the architecture from the start, and result in ease of use and stability. Linux is a modular operating system that is designed to easily replace or remove components. System components can be upgraded and updated when needed. A Linux system can be a general-purpose development workstation or a purposefully minimized software appliance. 2 RH124-RHEL9.0-en-2-20220609 Chapter 1 | Get Started with Red Hat Enterprise Linux What Is Open Source Software? Open source software is software with source code that anyone can use, study, modify, and share. Source code is the set of human-readable instructions that are used to make a program. Code might be in interpretive form, such as a script, or compiled into a binary executable that the computer runs directly. Source code becomes copyrighted when created, and the copyright holder controls the terms under which the software can be copied, adapted, and distributed. Users can use the software according to its software license. Some software uses "proprietary" or "closed source" source code that only the originating person, team, or organization can see, or change, or distribute. Proprietary licenses typically restrict the user to running the program, and provide limited or no access to the source. Open source software is different. When a copyright holder provides software under an open source license, they grant the user the right to run the program and to view, modify, compile, and redistribute the source to others, royalty-free. Open source licensing promotes collaboration, sharing, transparency, and rapid innovation, because it encourages more people to modify and improve the software and to share enhancements more widely. Open source software can still be provided for use for commercial purposes. Open source is a critical part of many organizations' commercial operations. Some open source licenses allow code to be reused in proprietary products. Anyone can sell open source code, but open source licensing generally allows the customer to redistribute the source code. Open source vendors such as Red Hat provide commercial support for deploying, managing, and building solutions that are based on open source products. Open source has many benefits for the user: Control: See what the code does and improve it. Training: Learn from real-world code and develop more useful applications. Security: Inspect sensitive code, and fix it even without the original developers' help. Stability: Rely on code that can survive the loss of the original developer. Types of Open Source Licenses The developers of open source software can license their software in different ways. The software license terms control how the source can be combined with other code or reused. To be open source, licenses must allow users to freely use, view, change, compile, and distribute the code. Two general classes of open source license are particularly important: Copyleft licenses are designed to encourage keeping the code open source. Permissive licenses are designed to maximize code reusability. Copyleft, or "share-alike" licenses, require that anyone who distributes the source code, with or without changes, must pass along the freedom for others to also copy, change, and distribute the code. The advantage of copyleft licenses is that they help to keep existing code, and improvements to that code, open and increase the amount of available open source code. Common copyleft licenses include the GNU General Public License (GPL) and the Lesser GNU Public License (LGPL). Permissive licenses maximize the reusability of source code. You can use the source for any purpose if the copyright and license statements are preserved, including reusing code under more restrictive or proprietary licenses. Although permissive licensing makes it easy to reuse code, it risks encouraging proprietary-only enhancements. Examples of permissive licenses include the MIT/X11 license, the Simplified BSD license, and the Apache Software License 2.0. RH124-RHEL9.0-en-2-20220609 3 Chapter 1 | Get Started with Red Hat Enterprise Linux Who Develops Open Source Software? Open source development today is overwhelmingly professional. Open source is no longer solely developed by an army of volunteers. Today, most open source developers work for organizations that pay them to participate with open source projects to construct and contribute the enhancements that the organization and their customers need. Volunteers and the academic community still play a significant role and can make vital contributions, especially in emerging technology. The combination of formal and informal development provides a highly dynamic and productive environment. Who Is Red Hat? Red Hat is the world's leading provider of open source software solutions, by using a community- powered approach to reliable and high-performance cloud, Linux, middleware, storage, and virtualization technologies. The mission of Red Hat mission is to be the catalyst in communities of customers, contributors, and partners to create better technology the open source way. The role of Red Hat role is to help customers to connect with the open source community and their partners to effectively use open source software solutions. Red Hat actively participates in and supports the open source community. Many years of experience have convinced the company of the importance of open source to the future of the IT industry. Red Hat is best known for its participation in the Linux community and the Red Hat Enterprise Linux distribution. However, Red Hat is also active in other open source communities, including middleware projects that are centered on the JBoss developer community, virtualization solutions, cloud technologies such as OpenStack and OpenShift, and the Ceph and Gluster software-based storage projects, plus others. What Is a Linux Distribution? A Linux distribution is an installable operating system that is constructed from a Linux kernel and that supports user programs and libraries. A complete Linux system is developed by multiple independent development communities that work cooperatively on individual components. A distribution provides an easy method to install and manage a working Linux system. In 1991, graduate student Linus Torvalds developed a UNIX-like kernel that he named Linux, and licensed it as open source software under the GPL. The kernel is the core of the operating system and manages hardware, memory, and the scheduling of running programs. The Linux kernel is supplemented with other open source software, including utilities and programs from the GNU Project, a graphical interface from MIT's X Window System, and other open source components, such as the Sendmail mail server and the Apache HTTP web server, to become a complete open source UNIX-like operating system. A major challenge for Linux users is to assemble all these software pieces from many sources. Early Linux developers provided a distribution of prebuilt and tested tools that users could download and install to quickly implement Linux systems. Many Linux distributions exist, each with differing goals and support criteria. Generally, distributions have some common characteristics: Distributions consist of a Linux kernel and support user-space programs. Distributions can be small and single-purpose, or can include thousands of open source programs. Distributions provide a means to install and update the software and its components. The distribution provider supports the software, and ideally, participates in the development community. 4 RH124-RHEL9.0-en-2-20220609 Chapter 1 | Get Started with Red Hat Enterprise Linux Red Hat Enterprise Linux Ecosystem Red Hat Enterprise Linux (RHEL) is Red Hat's commercial production-grade Linux distribution. Red Hat develops and integrates open source software into RHEL through a multistage process. Red Hat participates in supporting individual open source projects. It contributes code, developer time, resources, and support, and often collaborates with developers from other Linux distributions, to improve the general quality of software for everyone. Red Hat sponsors and integrates open source projects into the community-driven Fedora distribution. Fedora provides a free working environment to serve as a development lab and proving ground for features to be incorporated into CentOS Stream and RHEL products. Red Hat stabilizes the CentOS Stream software to be ready for long-term support and standardization, and integrates it into RHEL, the production-ready distribution. Figure 1.1: The Red Hat Enterprise Linux ecosystem Fedora Fedora is a community project that produces and releases a free, comprehensive Linux-based operating system. Red Hat sponsors and works with the Fedora community to integrate the latest upstream software into a fast-moving, secure distribution. The Fedora project contributes back to the open source world, and anyone can participate. Fedora prioritizes innovation and excellence above long-term stability. Major updates occur every six months, and bring significant changes. Fedora supports releases for about a year, which means the latest two updates, making it less suited for supportable production use. Fedora remains the source of innovation for the entire Enterprise Linux ecosystem. In general, packages start out in Fedora and are included into CentOS Stream only when they are considered mature in stability, security, performance, and customer demand. RH124-RHEL9.0-en-2-20220609 5 Chapter 1 | Get Started with Red Hat Enterprise Linux Extra Packages for Enterprise Linux A Fedora project Special Interest Group (SIG) builds and maintains a community-supported package repository called Extra Packages for Enterprise Linux (EPEL). EPEL versions align with major RHEL releases, and enable RHEL customers to run workloads with software dependencies that are not supported in RHEL. EPEL packages are not included in Red Hat support, but are equivalent to Fedora's level of quality. Typically, EPEL packages are built against RHEL releases. EPEL Next is an additional repository for package maintainers to build against CentOS Stream. This repository is useful when CentOS Stream contains an upcoming RHEL library rebase, or if an EPEL package has a minimum version build requirement that is already in CentOS Stream but not yet in RHEL. CentOS Stream CentOS Stream is the upstream project for RHEL. Development of the next RHEL version is transparent and open for community contributions that can directly influence the next release. Patches that are submitted to CentOS Stream are integrated faster to RHEL, to allow significant changes during the current RHEL version lifecycle. CentOS Stream is a continuous integration and delivery distribution, with tested and stable nightly builds. The CentOS project welcomes contributors worldwide, to give RHEL derivatives the opportunity to contribute to CentOS Stream for their own benefit. The CentOS project also aims to promote sustainable open source software that responds faster to security exploits, emerging technologies, and changing customer requirements. Note Before 2019, CentOS Linux was a free, unsupported distribution, community-built from Red Hat's source code after each major RHEL release. Although the CentOS community enjoyed having a free RHEL clone, this model had disadvantages. Commonly, developer contributions to CentOS Linux were not backported to Fedora or RHEL without considerable duplicate effort. Also, significant delays occurred between a RHEL release and its corresponding CentOS distribution build, with a similar delay for critical RHEL security, driver, and tuning fixes. Red Hat switched to the CentOS Stream model to address these issues. A benefit of CentOS Stream is that, as the source for RHEL development, it is available in all the same architectures as RHEL, including Intel/AMD x86_64, ARM64, IBM Power, and IBM Z. Numerous innovative technology organizations have proven that CentOS Stream is a viable replacement for the original downstream CentOS Linux. CentOS Stream can be freely downloaded and installed for many use cases, including development and light production. For community users with use cases that are not suitable for a continuously delivered distribution with asynchronous patch releases, Red Hat provides free individual RHEL developer subscriptions for small-scale use, such as demos, prototyping, quality assurance, and limited production. Red Hat Enterprise Linux Red Hat Enterprise Linux (RHEL) is Red Hat's production-ready, commercially supported Linux distribution. In the computing industry, RHEL is acknowledged as the leading platform for open source computing, because it is extensively tested and has a worldwide ecosystem of support partners for hardware and software certifications, consulting services, training, and multi-year support and maintenance guarantees. 6 RH124-RHEL9.0-en-2-20220609 Chapter 1 | Get Started with Red Hat Enterprise Linux Red Hat builds RHEL major releases directly from the CentOS Stream continuous development project, which is sourced from Fedora. In contrast with the previous development model, where RHEL releases were constructed internally with less transparency, and the source was provided only for building as CentOS Linux after the RHEL release, the new CentOS Stream development model is open and available to all, for feedback and contribution, while the code is prepared to be the next major RHEL release. RHEL uses a subscription-based support model, and does not charge license fees for open- source software. Red Hat support subscriptions provide product support, maintenance, updates, security patches, and access to the Customer Portal Knowledgebase, utilities, and downloadable releases of Red Hat products. The following table lists some key differences between Fedora, CentOS Stream, and RHEL. Fedora CentOS RHEL Stream Expected lifecycle 12-18 months 5 years 10 years Software vendor certified No Usually not Yes Documentation provided by Community Community Red Hat Expert support available No No Yes Product security team No No Yes Security certifications No No Yes No-cost options Yes Yes Yes Management tools No No Yes RHEL for Edge RHEL for Edge is an image-based variant of RHEL, with a different deployment mechanism. RHEL provides the ability to create purpose-built operating system images through a tool called Image Builder. With this mechanism, IT teams can build, deploy, and maintain these RHEL images in less time over the life of the system. Image-based deployments are optimized for various edge architectures, but are customizable for specific edge deployments. The Edge features in RHEL include secure management and scaling capabilities, including zero- touch provisioning, system health visibility, and quick security remediations from within a single interface. Red Hat CoreOS RHEL CoreOS (RHCOS) is not a stand-alone operating system, but it is built from RHEL components, and is then released, upgraded, and managed as part of the Red Hat OpenShift Container Platform (RHOCP) for cloud-native applications. RHCOS is fundamentally an image- based RHEL container host, which uses the Container Runtime Interface (CRI-O)-compliant container engine that is integrated in RHOCP. To learn more about Red Hat CoreOS, begin by becoming familiar with OpenShift and containers. RH124-RHEL9.0-en-2-20220609 7 Chapter 1 | Get Started with Red Hat Enterprise Linux Red Hat Universal Base Image A Red Hat Universal Base Image (UBI) is essentially a freely redistributable derivative of RHEL. UBI is designed to be a foundation for cloud-native and web application use cases that are developed in containers. All UBI content is a subset of RHEL, with packages sourced from secure RHEL channels, and UBI is supported similar to RHEL when run on a Red Hat supported platforms such as OpenShift and RHEL hosts. With UBI, developers can focus their efforts on their application in the container image. UBI is a set of base images, a set of application images (such as python, ruby, node.js, httpd, or nginx), and a set of RPM repositories from which you can update any UBI base image to include the package dependencies that your application requires. Red Hat Enterprise Linux Continuous Development In the Fedora upstream community, Fedora Rawhide is the continuous development environment for a regular cadence of public Fedora releases. The community tests and prepares new Linux kernel versions, device drivers, utilities, and applications for the next Fedora distribution. Major RHEL release development begins with selection of the latest Fedora release as the base for the current CentOS Stream continuous development distribution. Before a package is formally introduced to CentOS Stream, it undergoes rigorous testing to meet the standards for packages to be included in RHEL. Updates posted to CentOS Stream are identical to those posted to the unreleased minor version of RHEL in development. Figure 1.2: Red Hat Enterprise Linux continuous development As shown in Figure 1.2, Fedora 34 is the original code base for RHEL 9 and and for CentOS Stream 9. As packages are updated, they are then pushed into CentOS Stream and the nightly build of RHEL. The solid lines indicate distributions or builds that are available for public use. Similar to the relationship between Fedora Rawhide and Fedora, CentOS Stream is the continuous development environment for preparing the next minor-version RHEL release. Red Hat performs extensive hardware, integration, dependency, and performance testing before releasing the next public RHEL distribution. Obtaining Red Hat Enterprise Linux Red Hat Enterprise Linux is typically obtained with a paid support subscription, and Red Hat provides multiple ways to obtain RHEL and other RHEL ecosystem products, many without cost. Fedora Linux and derivatives are freely available from the Fedora project at https:// getfedora.org/, including an emerging version of Fedora CoreOS. EPEL and EPEL Next packages are freely available from the EPEL project repositories. Learn how to use EPEL at https://docs.fedoraproject.org/en-US/epel/. CentOS Stream is freely available at https://www.centos.org/centos-stream/. 8 RH124-RHEL9.0-en-2-20220609 Chapter 1 | Get Started with Red Hat Enterprise Linux RHEL Evaluation Download An evaluation copy of RHEL is available at https://access.redhat.com/products/red-hat- enterprise-linux/evaluation. You must have a (free) Customer Portal account for https:// access.redhat.com to access and download evaluation products. Product evaluations entitle you to receive updates and support for a limited period. Support ends when the evaluation period ends, but the evaluation software continues to operate. Additional information for many product evaluations is found on the Customer Portal evaluation pages. Red Hat Developer Subscription Red Hat provides a free subscription for many products through the Red Hat Developer Program at https://developer.redhat.com. With a Developer subscription, developers can quickly create, prototype, test, and demonstrate their applications on the same Red Hat software as on production systems. Create a personal account at https://access.redhat.com, and then register for the Developer program. You can use an existing personal account, but do not use an account that is already associated with any organization's support subscription. The Developer subscription is self-supported, but provides ongoing product updates. Red Hat recommends that individuals who want to gain experience with RHEL and developer products should join the Developer Program. Public Cloud Platforms The major hyperscale public cloud providers, such as Amazon Web Services, Google Cloud Platform, and Microsoft Azure, offer official images for deploying Red Hat Enterprise Linux instances, with subscription management from the Red Hat Cloud Access service. Fully entitled subscriptions for RHEL and Red Hat products are available through the cloud provider, and are portable in hybrid and multi-vendor clouds. Containers You can use Red Hat Universal Base Images and associated content for development and deployment without a Red Hat subscription. For operational support and access to non-UBI tools, containers that are built on UBI must be deployed on a Red Hat-supported platform such as OpenShift or Red Hat Enterprise Linux. Access to non-UBI content requires a Red Hat subscription. References Get Started with Red Hat Enterprise Linux https://access.redhat.com/products/red-hat-enterprise-linux#getstarted No-cost Red Hat Enterprise Linux Individual Developer Subscription: FAQs https://developers.redhat.com/articles/faqs-no-cost-red-hat-enterprise-linux# The Open Source Way https://opensource.com/open-source-way Fedora https://getfedora.org/ Red Hat Universal Base Images https://developers.redhat.com/products/rhel/ubi Red Hat Cloud Access https://www.redhat.com/en/technologies/cloud-computing/cloud-access RH124-RHEL9.0-en-2-20220609 9 Chapter 1 | Get Started with Red Hat Enterprise Linux Quiz Get Started with Red Hat Enterprise Linux Choose the correct answers to the following questions: 1. Which two statements are benefits of open source software for the user? (Choose two.) a. Code can survive the loss of the original developer or distributor. b. Sensitive portions of code are protected and available only to the original developer. c. You can learn from real-world code and develop more effective applications. d. Code remains open provided that it is in a public repository, but the license might change when included with closed source software. 2. Which two statements are ways in which Red Hat develops products for the future and interacts with the community? (Choose two.) a. Sponsor and integrate open source projects into the community-driven Fedora project. b. Develop specific integration tools that are available only in Red Hat distributions. c. Participate in upstream projects. d. Repackage and relicense community products. 3. Which two statements describe the benefits of Linux? (Choose two.) a. Linux is developed entirely by volunteers, which makes it a low-cost operating system. b. Linux is modular and can be configured as a full graphical desktop or a small appliance. c. Linux is locked in a known state for a minimum of one year for each release, so it is easier to develop custom software. d. Linux includes a powerful and scriptable command-line interface, which enables easier automation and provisioning. 10 RH124-RHEL9.0-en-2-20220609 Chapter 1 | Get Started with Red Hat Enterprise Linux Solution Get Started with Red Hat Enterprise Linux Choose the correct answers to the following questions: 1. Which two statements are benefits of open source software for the user? (Choose two.) a. Code can survive the loss of the original developer or distributor. b. Sensitive portions of code are protected and available only to the original developer. c. You can learn from real-world code and develop more effective applications. d. Code remains open provided that it is in a public repository, but the license might change when included with closed source software. 2. Which two statements are ways in which Red Hat develops products for the future and interacts with the community? (Choose two.) a. Sponsor and integrate open source projects into the community-driven Fedora project. b. Develop specific integration tools that are available only in Red Hat distributions. c. Participate in upstream projects. d. Repackage and relicense community products. 3. Which two statements describe the benefits of Linux? (Choose two.) a. Linux is developed entirely by volunteers, which makes it a low-cost operating system. b. Linux is modular and can be configured as a full graphical desktop or a small appliance. c. Linux is locked in a known state for a minimum of one year for each release, so it is easier to develop custom software. d. Linux includes a powerful and scriptable command-line interface, which enables easier automation and provisioning. RH124-RHEL9.0-en-2-20220609 11 Chapter 1 | Get Started with Red Hat Enterprise Linux Summary Open source software has source code that anyone can freely use, study, modify, and share. A Linux distribution is an installable operating system that is constructed from a Linux kernel and that supports user programs and libraries. Red Hat participates in supporting and contributing code to open source projects, sponsors and integrates project software into community-driven distributions, and stabilizes the software to offer it as supported enterprise-ready products. Red Hat Enterprise Linux is the Red Hat open source, enterprise-ready, commercially supported Linux distribution. A free Red Hat Developer Subscription is a useful method for obtaining free resources and information, including a 16-node version of Red Hat Enterprise Linux. 12 RH124-RHEL9.0-en-2-20220609 Chapter 2 Access the Command Line Goal Log in to a Linux system and run simple commands from the shell. Objectives Log in to a Linux system and run simple commands with the shell. Log in to the Linux system with the GNOME desktop environment to run commands from a shell prompt in a terminal program. Save time when running commands from a shell prompt with Bash shortcuts. Sections Access the Command Line (and Quiz) Access the Command Line with the Desktop (and Guided Exercise) Execute Commands with the Bash Shell (and Quiz) Lab Access the Command Line RH124-RHEL9.0-en-2-20220609 13 Chapter 2 | Access the Command Line Access the Command Line Objectives Log in to a Linux system and run simple commands with the shell. Introduction to the Bash Shell A command line is a text-based interface that is used to input instructions to a computer system. The Linux command line is provided by a program called the shell. Many shell program variants have been developed over the years. Every user can use a different shell, but the Red Hat recommends using the default shell for system administration. The default user shell in Red Hat Enterprise Linux (RHEL) is the GNU Bourne-Again Shell (bash). The bash shell is an improved version of the original Bourne Shell (sh) on UNIX systems. The shell displays a string when it is waiting for user input, called the shell prompt. When a regular user starts a shell, the prompt includes an ending dollar ($) character: [user@host ~]$ A hash (#) character replaces the dollar ($) character when the shell is running as the superuser, root. This character indicates that it is a superuser shell, which helps to avoid mistakes that can affect the whole system. [root@host ~]# Using bash to execute commands can be powerful. The bash shell provides a scripting language that can support task automation. The shell has capabilities that can enable or simplify operations that are hard to accomplish at scale with graphical tools. Note The bash shell is conceptually similar to the Microsoft Windows cmd.exe command-line interpreter. However, bash has a sophisticated scripting language, and is more similar to Windows PowerShell. On macOS, bash was the default shell until recently. In macOS 10.15 Catalina, Apple changed the default shell to zsh, an alternative shell that is also available in RHEL. Shell Basics Commands that are entered at the shell prompt have three basic parts: Command to run. Options to adjust the behavior of the command. Arguments, which are typically targets of the command. 14 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line The command is the name of the program to run. It might be followed by one or more options, which adjust the behavior of the command or what it will do. Options normally start with one or two dashes (-a or --all, for example) to distinguish them from arguments. Commands might also be followed by one or more arguments, which often indicate a target that the command should operate on. For example, in the usermod -L user01 string, usermod is the command, -L is the option, and user01 is the argument. This command locks the password of the user01 user account. Log in to a Local System A terminal is a text-based interface to enter commands into and print output from a computer system. To run the shell, you must log in to the computer on a terminal. A hardware keyboard and display for input and output might be directly connected to the computer. This is the physical console from the Linux machine. The physical console supports multiple virtual consoles, which can run on separate terminals. Each virtual console supports an independent login session. You can switch between the virtual consoles by pressing Ctrl+Alt and a function key (F1 through F6) at the same time. Most of these virtual consoles run a terminal that provides a text login prompt. If you enter your username and password correctly, then you log in and get a shell prompt. The computer might provide a graphical login prompt on one of the virtual consoles. You can use the graphical login prompt to log in to a graphical environment. The graphical environment also runs on a virtual console. To get a shell prompt, you must start a terminal program in the graphical environment. The shell prompt is provided in an application window of your graphical terminal program. Note Many system administrators choose not to run a graphical environment on their servers, because users do not log into servers as a desktop workspace. A server's workload can more effectively use the significant resources that a graphical environment uses. In Red Hat Enterprise Linux 9, if the graphical environment is available, then the login screen runs on the first virtual console, which is called tty1. Five additional text login prompts are available on virtual consoles two tty2 through six tty6. The graphical environment starts on the first virtual console that a login session is not currently using. Normally, your graphical session replaces the login prompt on the second virtual console (tty2). However, if an active text login session (not just a login prompt) is using that console, then the next free virtual console is used instead. The graphical login screen continues to run on the first virtual console (tty1). If you are already logged in to a graphical session, and log in as another user on the graphical login screen or use the Switch User menu item to switch users in the graphical environment without logging out, then another graphical environment is started for that user on the next free virtual console. When you log out of a graphical environment, it exits the virtual console and the physical console automatically switches back to the graphical login screen on the first virtual console. RH124-RHEL9.0-en-2-20220609 15 Chapter 2 | Access the Command Line Note In Red Hat Enterprise Linux 6 and 7, the graphical login screen runs on the first virtual console, but when you log in, your initial graphical environment replaces the login screen on the first virtual console instead of starting on a new virtual console. In Red Hat Enterprise Linux 8, the behavior is the same as in Red Hat Enterprise Linux 9. A headless server does not have a keyboard and display permanently connected to it. A data center might be filled with many racks of headless servers, and not providing each with a keyboard and display saves space and expense. For administrators to log in, a login prompt for a headless server might be provided by its serial console, which runs on a serial port that is connected to a networked console server for remote access. The serial console is normally used to access the server if the server network card becomes misconfigured and logging to the server over the conventional network connection becomes impossible. Most of the time, however, headless servers are accessed by other means over the network for example using Virtual Network Computing (VNC) for running graphical interface on the target machine. Log in to a Remote System Linux users and administrators often need to get shell access to a remote system by connecting to it over the network. In a modern computing environment, many headless servers are virtual machines or are running as public or private cloud instances. These systems are not physical and do not have real hardware consoles. They might not even provide access to their (simulated) physical console or serial console. In Linux, the most common way to get a shell prompt on a remote system is to use Secure Shell (SSH). Most Linux systems (including Red Hat Enterprise Linux) and macOS provide the OpenSSH command-line program ssh for this purpose. In this example, a user with a shell prompt on the machine host uses ssh to log in to the remote Linux system remotehost as the user remoteuser: [user@host ~]$ ssh remoteuser@remotehost remoteuser@remotehost's password: password [remoteuser@remotehost ~]$ The ssh command encrypts the connection to secure the communication against eavesdropping or hijacking of the passwords and content. Some systems, such as new cloud instances, for tighter security do not allow users to use a password to log in with ssh. An alternative way to authenticate to a remote machine without entering a password is through public key authentication. With this authentication method, users have a special identity file with a private key, which is equivalent to a password, and which they keep secret. Their account on the server is configured with a matching public key, which does not have to be secret. When logging in, users can configure ssh to provide the private key. If their matching public key is installed in that account on that remote server, then it logs in the user without asking for a password. In the next example, a user with a shell prompt on the host machine logs in to remotehost as remoteuser with ssh, by using the public key authentication method. The ssh command -i 16 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line option is used to specify the user's private key file, which is mylab.pem. The matching public key is already set up as an authorized key in the remoteuser account. [user@host ~]$ ssh -i mylab.pem remoteuser@remotehost [remoteuser@remotehost ~]$ For the connection to work, only the user who owns the file can have access to read the private key file. In the preceding example, where the private key is in the mylab.pem file, you can use the command chmod 600 mylab.pem to ensure that only the owner can read the file. How to set file permissions is discussed in more detail in a later chapter. Users might also have configured private keys that are tried automatically, but that discussion is beyond the scope of this section. The References at the end of this section contain links to more information about this topic. Note When you first log in to a new machine, you are prompted with a warning from ssh that it cannot establish the authenticity of the host: [user@host ~]$ ssh -i mylab.pem remoteuser@remotehost The authenticity of host 'remotehost (192.0.2.42)' can't be established. ECDSA key fingerprint is 47:bf:82:cd:fa:68:06:ee:d8:83:03:1a:bb:29:14:a3. Are you sure you want to continue connecting (yes/no)? yes [remoteuser@remotehost ~]$ Each time that you connect to a remote host with ssh, the remote host sends its host key to authenticate itself and to help to set up encrypted communication. The ssh command compares the host key against a list of saved host keys to ensure that it is not changed. If the host key changed, then it might indicate that someone is trying to pretend to be that host to hijack the connection, which is also known as an interceptor attack. In SSH, host keys protect against interceptor attacks; these host keys are unique for each server; and they need to be changed periodically and whenever a compromise is suspected. You get this warning when your local machine does not have a saved host key for the remote host. If you enter yes, then the host key that the remote host sent is accepted and saved for future reference. The login process continues, and you should not see this message again when connecting to this host. If you enter no, then the host key is rejected and the connection is closed. If the local machine does have a saved host key and it does not match the one that the remote host sent, then the connection is closed automatically with a warning. Log Out from a Remote System When you are finished with the shell and want to quit, you can choose one of several ways to end the session. You can enter the exit command to terminate the current shell session. Alternatively, finish a session by pressing Ctrl+D. The following example shows a user logging out of an SSH session: RH124-RHEL9.0-en-2-20220609 17 Chapter 2 | Access the Command Line [remoteuser@remotehost ~]$ exit logout Connection to remotehost closed. [user@host ~]$ References intro(1), bash(1), pts(4), ssh(1), and ssh-keygen(1) man pages For more information about OpenSSH and public key authentication, refer to the Using Secure Communications between Two Systems with OpenSSH chapter in the Red Hat Enterprise Linux 9 Securing Networks guide at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html- single/securing_networks/index Instructions on how to read man pages and other online help documentation are included at the end of the next section. 18 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line Quiz Access the Command Line Choose the correct answer to the following questions: 1. Which term describes the interpreter that executes commands that are typed as strings? a. Command b. Console c. Shell d. Terminal 2. Which term describes the visual cue that indicates that an interactive shell is waiting for the user to type a command? a. Argument b. Command c. Option d. Prompt 3. Which term describes the name of a program to run? a. Argument b. Command c. Option d. Prompt 4. Which term describes the part of the command line that adjusts the behavior of a command? a. Argument b. Command c. Option d. Prompt 5. Which term describes the part of the command line that specifies the target that the command should operate on? a. Argument b. Command c. Option d. Prompt RH124-RHEL9.0-en-2-20220609 19 Chapter 2 | Access the Command Line 6. Which term describes the hardware display and keyboard to interact with a system? a. Physical Console b. Virtual Console c. Shell d. Terminal 7. Which term describes one of multiple logical consoles that can each support an independent login session? a. Physical Console b. Virtual Console c. Shell d. Terminal 8. Which term describes an interface that provides a display for output and a keyboard for input to a shell session? a. Console b. Virtual Console c. Shell d. Terminal 20 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line Solution Access the Command Line Choose the correct answer to the following questions: 1. Which term describes the interpreter that executes commands that are typed as strings? a. Command b. Console c. Shell d. Terminal 2. Which term describes the visual cue that indicates that an interactive shell is waiting for the user to type a command? a. Argument b. Command c. Option d. Prompt 3. Which term describes the name of a program to run? a. Argument b. Command c. Option d. Prompt 4. Which term describes the part of the command line that adjusts the behavior of a command? a. Argument b. Command c. Option d. Prompt 5. Which term describes the part of the command line that specifies the target that the command should operate on? a. Argument b. Command c. Option d. Prompt RH124-RHEL9.0-en-2-20220609 21 Chapter 2 | Access the Command Line 6. Which term describes the hardware display and keyboard to interact with a system? a. Physical Console b. Virtual Console c. Shell d. Terminal 7. Which term describes one of multiple logical consoles that can each support an independent login session? a. Physical Console b. Virtual Console c. Shell d. Terminal 8. Which term describes an interface that provides a display for output and a keyboard for input to a shell session? a. Console b. Virtual Console c. Shell d. Terminal 22 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line Access the Command Line with the Desktop Objectives Log in to the Linux system with the GNOME desktop environment to run commands from a shell prompt in a terminal program. Introduction to the GNOME Desktop Environment The desktop environment is the graphical user interface on a Linux system. GNOME 40 is the default desktop environment in Red Hat Enterprise Linux 9. It provides an integrated desktop for users and a unified development platform on top of a graphical framework provided by either Wayland (by default) or the legacy X Window System. GNOME Shell provides the core user interface functions for the GNOME desktop environment. The GNOME Shell application is highly customizable. Red Hat Enterprise Linux 9 defaults the GNOME Shell appearance to the "Standard" theme, which is used in this section. You can default to an alternative "Classic" theme, which is closer to the appearance of older versions of GNOME, and which is used on previous RHEL versions. You can select either theme persistently at login by clicking the gear icon next to the Sign In button. The gear icon is available after selecting your account but before entering your password. Figure 2.1: The RHEL 9 login screen RH124-RHEL9.0-en-2-20220609 23 Chapter 2 | Access the Command Line The first time that you log in as a new user, you can take an optional initial "Take Tour" program to learn about the new RHEL 9 features. After you either complete it or skip it, the main GNOME screen appears. To review the documentation in GNOME Help, click the Activities button on the left side of the top bar. In the dash at the bottom of the screen, click the life ring buoy icon to launch it. Parts of the GNOME Shell The elements of the GNOME Shell include the following parts, as shown in this screen capture of the GNOME Shell in Activities overview mode: Top bar: The bar that runs along the top of the screen. It is displayed in the Activities overview and in workspaces. The top bar provides the Activities button and controls for volume, networking, calendar access, and switching between keyboard input methods (if more than one method is configured). Activities overview: This mode helps to organize windows and start applications. Enter the Activities overview by clicking the Activities button at the upper-left corner of the top bar, or by pressing the Super key. Find the Super key (sometimes called the Windows key or Command key) near the lower-left corner of most common keyboards. The three main areas are the dash at the bottom of the screen, the windows overview in the center, and the workspace selector on the right side. System menu: The menu in the upper-right corner on the top bar provides control to adjust the brightness of the screen, and to switch on or off the network connections. Under the submenu for the user's name are options to adjust account settings and to log out of the system. The system menu also offers buttons to open the Settings window, lock the screen, or shut down the system. Dash: This configurable list of icons shows your favorite applications, running applications, and a Show Applications button to select arbitrary applications. Start applications by clicking an icon or by using the Show Applications button to find less commonly used applications. The dash is also called the dock. 24 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line Windows overview: The area in the center of the Activities overview that displays thumbnails of active windows in the current workspace, for bringing windows to the foreground on a cluttered workspace, or moving them to another workspace. Workspace selector: An area to the right which displays thumbnails of active workspaces and allows workspaces to be selected and windows to be moved from one workspace to another. Message tray: With the message tray, you can review notifications from applications or system components. If a notification occurs, the notification typically first appears briefly as a single line at the top of the screen, and a persistent indicator appears in the top bar next to the clock to inform you of recently received notifications. Open the message tray to review these notifications by clicking the clock on the top bar or by pressing Super+M. Close the message tray by clicking the clock on the top bar, or by pressing Esc or Super+M again. The message tray also shows the calendar and information about the events in the calendar. Figure 2.2: Closeup of an open message tray View and edit the GNOME keyboard shortcuts that your account uses. Open the system menu on the right side of the top bar. Click the Settings button on the bottom of the menu on the left. In the application window that opens, select Keyboard from the left pane. The right pane displays your current shortcut settings under the Keyboard Shorcuts > Customize Shorcuts section. Note Some keyboard shortcuts, such as function keys or the Super key, might be difficult to send to a virtual machine. Special keystrokes that those shortcuts use might be captured by your local operating system, or by the application that you are using to access the graphical desktop of your virtual machine. RH124-RHEL9.0-en-2-20220609 25 Chapter 2 | Access the Command Line Important In the current virtual training and self-paced training environments provided by Red Hat, use of the Super key can be tricky, because your web browser might not pass it to the virtual machine in the classroom environment. At the top of your browser window that displays the interface for your virtual machine, click the keyboard icon on the right side. An on-screen keyboard opens. Click the icon again to close the on-screen keyboard. The on-screen keyboard treats Super as a modifier key that is often held down while pressing another key. If you click it once, then it turns yellow, to indicate that the key is being held down. So for example, to enter Super+M in the on-screen keyboard, you can click Super and then click M. To press and release Super in the on-screen keyboard, then click it twice. The first click holds down the Super key, and the second click releases it. The other keys that the on-screen keyboard treats as modifier keys (like Super) are Shift, Ctrl, Alt, and Caps. The Esc and Menu keys are treated like normal keys and not modifier keys. Understand Workspaces Workspaces are separate desktop screens that have different application windows. You can use workspaces to organize the working environment by grouping open application windows by task. For example, you can group windows for a particular system maintenance activity (such as setting up a new remote server) in one workspace, while you can group email and other communication applications in another workspace. Choose between two methods to switch between workspaces. The first method is to press Ctrl+Alt+LeftArrow or Ctrl+Alt+RightArrow to switch between workspaces sequentially. The second is to switch to the Activities overview and click the chosen workspace. An advantage of using the Activities overview is that you can click and drag windows between workspaces by using the workspace selector on the right side of the screen and the windows overview in the center of the screen. Important Like Super, in the current virtual training and self-paced training environments provided by Red Hat, your web browser does not usually pass Ctrl+Alt key combinations to the virtual machine in the classroom environment. You can enter these key combinations to switch workspaces by using the on-screen keyboard. At least two workspaces must be in use. Open the on-screen keyboard and click Ctrl, Alt, and then either LeftArrow or RightArrow. However, in those training environments, it is generally simpler to avoid the keyboard shortcuts and the on-screen keyboard. Switch workspaces by clicking the Activities button and then, in the workspace selector to the right of the Activities overview, clicking the workspace to switch to. 26 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line Start a Terminal To get a shell prompt in GNOME, start a graphical terminal application such as GNOME Terminal. Use one of the following methods to start a terminal: From the Activities overview, select Terminal from the dash, either in Favorites or with the Show Applications button. Search for terminal in the search field at the top of the windows overview). Press the Alt+F2 key combination to open the Enter a Command and enter gnome- terminal. When you open a terminal window, a shell prompt is displayed for the user who started the graphical terminal program. The shell prompt and the terminal window's title bar indicate the current username, hostname, and working directory. Lock the Screen and Log Out Lock the screen, or log out entirely, from the system menu on the far right of the top bar. To lock the screen, from the system menu in the upper-right corner, click the lock button at the bottom of the menu or press Super+L (which might be easier to remember as Windows+L). The screen also locks if the graphical session is idle for a few minutes. A lock screen curtain appears that shows the system time and the name of the logged-in user. To unlock the screen, you can press Enter, Space, or click the left mouse button. Then enter that user's password on the lock screen. To log out and end the current graphical login session, select the system menu in the upper-right corner on the top bar and select Power Off/Log out > Log Out. A window is displayed that offers the option to Cancel or confirm the Log Out action. Power Off or Reboot the System To shut down the system, from the system menu in the upper-right corner, select Power Off/Log out > Power Off or press Ctrl+Alt+Del. A window is displayed that offers the option to Cancel or confirm the Power Off action. If you do not make a choice, then the system automatically shuts down after 60 seconds. To reboot the system, from the system menu in the upper-right corner, select Power Off/Log out > Restart. A window is displayed that offers the option to Cancel or confirm the Restart action. If you do not make a choice, then the system automatically restarts after 60 seconds. References GNOME Help yelp GNOME Help: Visual overview of GNOME yelp help:gnome-help/shell-introduction GNOME 40 webpage https://forty.gnome.org/ RH124-RHEL9.0-en-2-20220609 27 Chapter 2 | Access the Command Line Guided Exercise Access the Command Line with the Desktop In this exercise, you log in through the graphical display manager as a regular user to become familiar with the GNOME Standard desktop environment provided by GNOME 40. Outcomes Log in to a Linux system using the GNOME 40 desktop environment Run commands from a shell prompt in a terminal program. Before You Begin As the student user on the workstation machine, use the lab command to prepare your system for this exercise. This command prepares your environment and ensures that all required resources are available. [student@workstation ~]$ lab start cli-desktop Instructions 1. Log in to workstation as student with student as the password. 1.1. On workstation, at the GNOME login screen, click the student user account. Enter student when prompted for the password. 1.2. Press Enter. 2. Change the password for student from student to 55TurnK3y. Important The finish script resets the password for the student user to student. You must execute the script at the end of the exercise. 2.1. Open a Terminal window and use the passwd command at the shell prompt. In the virtual learning environment with a visual keyboard, press the Super key twice to enter the Activities overview. Type terminal and then press Enter to start Terminal. 2.2. In the Terminal window that opens, type passwd at the shell prompt. Change the student password from student to 55TurnK3y. 28 RH124-RHEL9.0-en-2-20220609 Chapter 2 | Access the Command Line [student@workstation ~]$ passwd Changing password for user student. Current password: student New password: 55TurnK3y Retype new password: 55TurnK3y passwd: all authentication tokens updated successfully. 3. Log out and log back in as student with 55TurnK3y as the password to verify the changed password. 3.1. Click the system menu in the upper-right corner. 3.2. Select Power Off/Log Out > Log Out. 3.3. Click Log Out in the confirmation dialog box that is displayed. 3.4. At the GNOME login screen, click the student user account. Enter 55TurnK3y when prompted for the password. 3.5. Press Enter. 4. Lock the screen. 4.1. From the system menu in the upper-right corner, press the Lock button. 5. Unlock the screen. 5.1. Press Enter to unlock the screen. 5.2. In the Password field, enter 55TurnK3y as the password. 5.3. Press Enter. 6. Determine how to shut down workstation from the graphical interface, but Cancel the operation without shutting down the system. 6.1. From the system menu in the upper-right corner, select Power Off/Log Out > Power Off. A dialog box is displayed with the options to either Cancel or Power Off the machine. 6.2. Click Cancel in the dialog box that is displayed. Finish On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises. [student@workstation ~]$ lab finish cli-desktop This concludes the section. RH124-RHEL9.0-en-2-20220609 29 Chapter 2 | Access the Command Line Execute Commands with the Bash Shell Objectives Save time when running commands from a shell prompt with Bash shortcuts. Basic Command Syntax The GNU Bourne-Again Shell (bash) is a program that interprets commands that the user types. Each string that is typed into the shell can have up to three parts: the command, options (which usually begin with a hyphen - or double hyphen -- characters), and arguments. Each word that is typed into the shell is separated from other words with spaces. Commands are the names of programs that are installed on the system. Each command has its options and arguments. When you are ready to execute a command, press the Enter key. Type each command on a separate line. The command output is displayed before the following shell prompt appears. [user@host ~]$ whoami user [user@host ~]$ To type more than one command on a single line, use the semicolon (;) as a command separator. A semicolon is a member of a class of characters called metacharacters that have a special interpretation for bash. In this case, the output of both commands is displayed before the following shell prompt appears. The following example shows how to combine two commands (command1 and command2) on the command line. [user@host ~]$ command1 ; command2 command1 output command2 outp

Use Quizgecko on...
Browser
Browser