[RHCSA] 06 – Deploy, configure, and maintain systems

    06.1 – Schedule tasks using at and corn

    Overview

    Scheduling tasks is a fundamental aspect of system administration. The at command is used for one-time task scheduling, while cron is used for recurring tasks. This guide covers how to use both tools to automate tasks.


    Using at for One-Time Task Scheduling

    Installing at

    Ensure the at package is installed on your system.

    sudo yum install at

    Starting the atd Service

    Start and enable the atd service to ensure it runs at boot.

    sudo systemctl start atd
    sudo systemctl enable atd

    Scheduling a One-Time Task

    Use the at command to schedule a one-time task.

    Syntax

    at <time>

    Examples

    1. Schedule a Task for a Specific Time:
    echo "backup.sh" | at 02:00
    1. Schedule a Task for a Specific Date and Time:
    echo "backup.sh" | at 02:00 2023-10-01
    1. Schedule a Task for a Relative Time:
    echo "backup.sh" | at now + 1 hour

    Viewing Scheduled at Jobs

    Use the atq command to view the list of scheduled at jobs.

    atq

    Sample Output:

    1   2023-10-01 02:00 a user

    Removing Scheduled at Jobs

    Use the atrm command to remove a scheduled at job.

    atrm <job_id>

    Example

    atrm 1

    Using cron for Recurring Task Scheduling

    Understanding cron

    cron is a time-based job scheduler that allows you to run commands or scripts at specified times and intervals.

    Editing the Crontab

    Use the crontab command to edit the cron table (crontab) for scheduling recurring tasks.

    Syntax

    crontab -e

    Crontab Format

    The crontab file consists of lines with the following format:

    <minute> <hour> <day_of_month> <month> <day_of_week> <command>
    • <minute>: Minute (0-59)
    • <hour>: Hour (0-23)
    • <day_of_month>: Day of the month (1-31)
    • <month>: Month (1-12)
    • <day_of_week>: Day of the week (0-7, where 0 and 7 represent Sunday)
    • <command>: The command to execute

    Examples

    • Run a Script Every Day at 2 AM:
    0 2 * * * /path/to/backup.sh
    • Run a Script Every Monday at 3 PM:
    0 15 * * 1 /path/to/weekly_report.sh
    • Run a Script Every 15 Minutes:
    */15 * * * * /path/to/check_status.sh
    • Run a Script on the First Day of Every Month at Midnight:
    0 0 1 * * /path/to/monthly_cleanup.sh

    Viewing Scheduled cron Jobs

    Use the crontab -l command to list the current user’s scheduled cron jobs.

    crontab -l

    Removing Scheduled cron Jobs

    Edit the crontab file and remove the line corresponding to the job you want to delete.

    crontab -e

    Practical Examples

    Example 1: Schedule a One-Time Task Using at

    1. Schedule a Task to Run a Script at 3 PM Today:
    echo "/path/to/script.sh" | at 15:00
    1. View Scheduled at Jobs:
    atq
    1. Remove a Scheduled at Job:
    atrm 1

    Example 2: Schedule a Recurring Task Using cron

    1. Edit the Crontab:
    crontab -e
    1. Add a Job to Run a Script Every Day at 5 AM:
    0 5 * * * /path/to/daily_task.sh
    1. View Scheduled cron Jobs:
    crontab -l
    1. Remove a Scheduled cron Job:Edit the crontab file and delete the corresponding line.crontab -e

    Additional Tips

    • Check cron Logs:View the cron logs to troubleshoot scheduled jobs.
    sudo tail -f /var/log/cron
    • Use crontab for Specific Users:Edit the crontab for a specific user.
    sudo crontab -u username -e
    • Use Environment Variables in Crontab:Set environment variables in the crontab file.
    MAILTO=user@example.com
    • Run cron Jobs with Specific Shell:Specify the shell to use for cron jobs.
    SHELL=/bin/bash

    Conclusion

    Scheduling tasks using at and cron allows for automation of one-time and recurring tasks, respectively. Mastery of these tools ensures efficient system administration and is a key competency for the RHCSA exam.


    These notes should help you understand how to schedule tasks using at and cron for the RHCSA exam.

    06.2 – Start and stop services and configure services to start automatically at boot

    Overview

    Managing services is a fundamental task in system administration. In RHEL, services are managed using systemd and the systemctl command. This guide covers how to start, stop, and configure services to start automatically at boot.


    Starting and Stopping Services

    Starting a Service

    Use the systemctl start command to start a service.

    Syntax

    sudo systemctl start <service_name>

    Example

    Start the SSH service:

    sudo systemctl start sshd

    Stopping a Service

    Use the systemctl stop command to stop a service.

    Syntax

    sudo systemctl stop <service_name>

    Example

    Stop the SSH service:

    sudo systemctl stop sshd

    Restarting a Service

    Use the systemctl restart command to restart a service.

    Syntax

    sudo systemctl restart <service_name>

    Example

    Restart the SSH service:

    sudo systemctl restart sshd

    Reloading a Service

    Use the systemctl reload command to reload a service’s configuration without stopping it.

    Syntax

    sudo systemctl reload <service_name>

    Example

    Reload the SSH service:

    sudo systemctl reload sshd

    Checking the Status of a Service

    Use the systemctl status command to check the status of a service.

    Syntax

    systemctl status <service_name>

    Example

    Check the status of the SSH service:

    systemctl status sshd

    Sample Output:

     sshd.service - OpenSSH server daemon
       Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2023-10-01 12:00:00 UTC; 1h 30min ago
         Docs: man:sshd(8)
               man:sshd_config(5)
     Main PID: 1234 (sshd)
        Tasks: 1
       Memory: 5.0M
       CGroup: /system.slice/sshd.service
               └─1234 /usr/sbin/sshd -D

    Enabling and Disabling Services at Boot

    Enabling a Service

    Use the systemctl enable command to configure a service to start automatically at boot.

    Syntax

    sudo systemctl enable <service_name>

    Example

    Enable the SSH service to start at boot:

    sudo systemctl enable sshd

    Disabling a Service

    Use the systemctl disable command to prevent a service from starting automatically at boot.

    Syntax

    sudo systemctl disable <service_name>

    Example

    Disable the SSH service from starting at boot:

    sudo systemctl disable sshd

    Checking if a Service is Enabled

    Use the systemctl is-enabled command to check if a service is enabled to start at boot.

    Syntax

    systemctl is-enabled <service_name>

    Example

    Check if the SSH service is enabled:

    systemctl is-enabled sshd

    Sample Output:

    enabled

    Practical Examples

    Example 1: Start, Stop, and Restart the Apache HTTP Server

    1. Start the Apache HTTP Server:
    sudo systemctl start httpd
    1. Check the Status of the Apache HTTP Server:
    systemctl status httpd
    1. Restart the Apache HTTP Server:
    sudo systemctl restart httpd
    1. Stop the Apache HTTP Server:
    sudo systemctl stop httpd

    Example 2: Enable and Disable the Firewall Service

    1. Enable the Firewall Service to Start at Boot:
    sudo systemctl enable firewalld
    1. Check if the Firewall Service is Enabled:
    systemctl is-enabled firewalld
    1. Disable the Firewall Service from Starting at Boot:
    sudo systemctl disable firewalld
    1. Check if the Firewall Service is Disabled:
    systemctl is-enabled firewalld

    Additional Tips

    • List All Services:Use the systemctl list-units command to list all services.
    systemctl list-units --type=service
    • List All Enabled Services:Use the systemctl list-unit-files command to list all enabled services.
    systemctl list-unit-files --type=service | grep enabled
    • Mask a Service:Use the systemctl mask command to prevent a service from being started manually or automatically.
    sudo systemctl mask <service_name>
    • Unmask a Service:Use the systemctl unmask command to remove the mask from a service.
    sudo systemctl unmask <service_name>
    • Reload Systemd Configuration:Use the systemctl daemon-reload command to reload the systemd manager configuration.
    sudo systemctl daemon-reload

    Conclusion

    Starting, stopping, and configuring services to start automatically at boot are essential tasks for system administration. Mastery of these tasks ensures that services are managed efficiently and reliably, which is crucial for the RHCSA exam.


    These notes should help you understand how to start and stop services and configure services to start automatically at boot for the RHCSA exam.

    06.3 – Configure systems to boot into a specific target automatically

    Overview

    In RHEL, systemd uses targets to define different states or modes of operation for the system. Targets are similar to runlevels in the older SysV init system. Configuring the system to boot into a specific target automatically is essential for controlling the system’s behavior at startup.


    Common Systemd Targets

    • graphical.target: Multi-user system with a graphical interface (equivalent to runlevel 5).
    • multi-user.target: Multi-user system without a graphical interface (equivalent to runlevel 3).
    • rescue.target: Single-user mode with basic system services (equivalent to runlevel 1).
    • emergency.target: Minimal environment for emergency maintenance.
    • reboot.target: Reboots the system.
    • poweroff.target: Shuts down the system.

    Viewing the Current Default Target

    Use the systemctl get-default command to view the current default target.

    systemctl get-default

    Sample Output:

    graphical.target

    Setting the Default Target

    Use the systemctl set-default command to set the default target.

    Syntax

    sudo systemctl set-default <target>

    Examples

    1. Set the Default Target to Multi-User Mode:
    sudo systemctl set-default multi-user.target
    1. Set the Default Target to Graphical Mode:
    sudo systemctl set-default graphical.target

    Verify the Change

    After setting the default target, verify the change using the systemctl get-default command.

    systemctl get-default

    Sample Output:

    multi-user.target

    Changing the Current Target

    To change the current target without rebooting, use the systemctl isolate command.

    Syntax

    sudo systemctl isolate <target>

    Examples

    1. Switch to Multi-User Mode:
    sudo systemctl isolate multi-user.target
    1. Switch to Graphical Mode:
    sudo systemctl isolate graphical.target

    Verify the Change

    Check the current target using the systemctl list-units --type=target command.

    systemctl list-units --type=target

    Sample Output:

    UNIT                LOAD   ACTIVE SUB    DESCRIPTION
    basic.target        loaded active active Basic System
    graphical.target    loaded active active Graphical Interface
    multi-user.target   loaded active active Multi-User System

    Practical Examples

    Example 1: Configure the System to Boot into Multi-User Mode

    1. Set the Default Target to Multi-User Mode:
    sudo systemctl set-default multi-user.target
    1. Verify the Default Target:
    systemctl get-default
    1. Reboot the System:
    sudo reboot
    1. Verify the Current Target After Reboot:
    systemctl list-units --type=target

    Example 2: Configure the System to Boot into Graphical Mode

    1. Set the Default Target to Graphical Mode:
    sudo systemctl set-default graphical.target
    1. Verify the Default Target:
    systemctl get-default
    1. Reboot the System:
    sudo reboot
    1. Verify the Current Target After Reboot:
    systemctl list-units --type=target

    Additional Tips

    • List All Available Targets:Use the systemctl list-unit-files --type=target command to list all available targets.
    systemctl list-unit-files --type=target
    • Check Dependencies of a Target:Use the systemctl list-dependencies <target> command to check the dependencies of a target.
    systemctl list-dependencies multi-user.target
    • Create Custom Targets:Custom targets can be created by defining new unit files in the /etc/systemd/system/ directory.
    • Emergency and Rescue Targets:Use emergency.target and rescue.target for troubleshooting and maintenance.
    sudo systemctl isolate emergency.target
    sudo systemctl isolate rescue.target

    Conclusion

    Configuring systems to boot into a specific target automatically is essential for controlling the system’s behavior at startup. Mastery of these tasks ensures that the system operates in the desired state, which is crucial for the RHCSA exam.


    These notes should help you understand how to configure systems to boot into a specific target automatically for the RHCSA exam.

    06.4 – Configure time service clients

    Overview

    Accurate timekeeping is crucial for system operations, logging, and security. In RHEL, chrony is the default NTP (Network Time Protocol) client and server used to synchronize the system clock with remote NTP servers. This guide covers how to configure chrony as a time service client.


    Installing Chrony

    Ensure the chrony package is installed on your system.

    sudo yum install chrony

    Configuring Chrony

    Step 1: Edit the Chrony Configuration File

    The main configuration file for chrony is /etc/chrony.conf.

    sudo nano /etc/chrony.conf

    Step 2: Configure NTP Servers

    Add or modify the server lines to specify the NTP servers you want to use. You can use public NTP servers or your organization’s NTP servers.

    Example Configuration

    # Use public servers from the pool.ntp.org project.
    server 0.centos.pool.ntp.org iburst
    server 1.centos.pool.ntp.org iburst
    server 2.centos.pool.ntp.org iburst
    server 3.centos.pool.ntp.org iburst
    
    # Allow NTP client access from local network.
    allow 192.168.0.0/16
    
    # Ignore stratum in source selection.
    stratumweight 0
    
    # Record the rate at which the system clock gains/losses time.
    driftfile /var/lib/chrony/drift
    
    # Enable kernel RTC synchronization.
    rtcsync
    • server <hostname> iburst: Specifies an NTP server to synchronize with. The iburst option speeds up the initial synchronization.
    • allow <subnet>: Allows NTP client access from the specified subnet.
    • driftfile: Specifies the location of the drift file.
    • rtcsync: Enables synchronization of the system clock with the hardware clock.

    Step 3: Start and Enable the Chrony Service

    Start the chronyd service and enable it to start at boot.

    sudo systemctl start chronyd
    sudo systemctl enable chronyd

    Step 4: Verify the Chrony Service

    Check the status of the chronyd service to ensure it is running.

    sudo systemctl status chronyd

    Sample Output:

     chronyd.service - NTP client/server
       Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2023-10-01 12:00:00 UTC; 1h 30min ago
         Docs: man:chronyd(8)
               man:chrony.conf(5)
     Main PID: 1234 (chronyd)
        Tasks: 1
       Memory: 1.5M
       CGroup: /system.slice/chronyd.service
               └─1234 /usr/sbin/chronyd

    Monitoring and Managing Chrony

    Check Synchronization Status

    Use the chronyc tracking command to check the synchronization status.

    chronyc tracking

    Sample Output:

    Reference ID    : 203.0.113.1 (ntp.example.com)
    Stratum         : 3
    Ref time (UTC)  : Mon Oct  1 13:30:00 2023
    System time     : 0.000000123 seconds fast of NTP time
    Last offset     : +0.000001234 seconds
    RMS offset      : 0.000001234 seconds
    Frequency       : 0.123 ppm slow
    Residual freq   : +0.000 ppm
    Skew            : 0.123 ppm
    Root delay      : 0.012345 seconds
    Root dispersion : 0.012345 seconds
    Update interval : 64.0 seconds
    Leap status     : Normal

    Check NTP Sources

    Use the chronyc sources command to list the NTP sources.

    chronyc sources

    Sample Output:

    210 Number of sources = 4
    MS Name/IP address         Stratum Poll Reach LastRx Last sample
    ===============================================================================
    ^* ntp1.example.com              2   6    17    64   +0ns[  +0ns] +/-  10ms
    ^+ ntp2.example.com              2   6    17    64   +0ns[  +0ns] +/-  10ms
    ^- ntp3.example.com              3   6    17    64   +0ns[  +0ns] +/-  10ms
    ^- ntp4.example.com              3   6    17    64   +0ns[  +0ns] +/-  10ms

    Force a Manual Synchronization

    Use the chronyc makestep command to force a manual synchronization.

    sudo chronyc makestep

    Practical Examples

    Example 1: Configure Chrony to Use Public NTP Servers

    1. Edit the Chrony Configuration File:
    sudo nano /etc/chrony.conf
    1. Add Public NTP Servers:
    server 0.centos.pool.ntp.org iburst
    server 1.centos.pool.ntp.org iburst
    server 2.centos.pool.ntp.org iburst
    server 3.centos.pool.ntp.org iburst
    1. Start and Enable the Chrony Service:
    sudo systemctl start chronydsudo systemctl enable chronyd
    1. Verify the Chrony Service:
    sudo systemctl status chronyd
    1. Check Synchronization Status:
    chronyc tracking

    Example 2: Configure Chrony to Use Internal NTP Servers

    1. Edit the Chrony Configuration File:
    sudo nano /etc/chrony.conf
    1. Add Internal NTP Servers:
    server ntp1.internal.example.com iburst
    server ntp2.internal.example.com iburst
    1. Allow NTP Client Access from the Local Network:
    allow 192.168.0.0/16
    1. Start and Enable the Chrony Service:
    sudo systemctl start chronyd
    sudo systemctl enable chronyd
    1. Verify the Chrony Service:
    sudo systemctl status chronyd
    1. Check NTP Sources:
    chronyc sources

    Additional Tips

    • Synchronize the Hardware Clock:Use the hwclock command to synchronize the hardware clock with the system clock.
    sudo hwclock --systohc
    • Check Chrony Logs:View the chrony logs for troubleshooting.
    sudo journalctl -u chronyd
    • Configure Time Zone:Use the timedatectl command to configure the system time zone.
    sudo timedatectl set-timezone America/New_York
    • Restart Chrony Service:Restart the chronyd service after making configuration changes.
    sudo systemctl restart chronyd

    Conclusion

    Configuring time service clients using chrony ensures accurate timekeeping, which is essential for system operations, logging, and security. Mastery of these tasks is crucial for the RHCSA exam.


    These notes should help you understand how to configure time service clients for the RHCSA exam.

    06.5 – Install and update software packages from Red Hat Network, a remote repository, or from the local file system

    Overview

    Managing software packages is a fundamental task in system administration. In RHEL, the yum and dnf package managers are used to install, update, and remove software packages. This guide covers how to install and update packages from Red Hat Network (RHN), remote repositories, and the local file system.


    Using yum and dnf

    Installing Packages

    From Red Hat Network (RHN) or Remote Repository

    1. Install a Package:
    sudo yum install <package_name>
    # or
    sudo dnf install <package_name>

    Example:

    sudo yum install httpd
    1. Install Multiple Packages:
    sudo yum install <package1> <package2>
    # or
    sudo dnf install <package1> <package2>

    Example:

    sudo yum install httpd mariadb-server

    From the Local File System

    1. Install a Package from a Local RPM File:
    sudo yum install /path/to/package.rpm
    # or
    sudo dnf install /path/to/package.rpm

    Example:

    sudo yum install /tmp/vim-enhanced-8.0.1763-15.el8.x86_64.rpm

    Updating Packages

    1. Update a Specific Package:
    sudo yum update <package_name>
    #or
    sudo dnf update <package_name>

    Example:

    sudo yum update httpd
    1. Update All Packages:
    sudo yum update
    # or
    sudo dnf update

    Removing Packages

    1. Remove a Package:
    sudo yum remove <package_name>
    # or
    sudo dnf remove <package_name>

    Example:

    sudo yum remove httpd

    Configuring Repositories

    Viewing Enabled Repositories

    Use the yum repolist or dnf repolist command to view the list of enabled repositories.

    sudo yum repolist

    or

    sudo dnf repolist

    Sample Output:

    repo id                   repo name
    rhel-8-for-x86_64-baseos  Red Hat Enterprise Linux 8 for x86_64 - BaseOS
    rhel-8-for-x86_64-appstream  Red Hat Enterprise Linux 8 for x86_64 - AppStream

    Adding a Remote Repository

    1. Create a Repository Configuration File:
    sudo nano /etc/yum.repos.d/myrepo.repo
    1. Add Repository Information:
    [myrepo]
    name=My Custom Repository
    baseurl=http://myrepo.example.com/repo
    enabled=1
    gpgcheck=1
    gpgkey=http://myrepo.example.com/repo/RPM-GPG-KEY-myrepo
    1. Save and Exit.

    Adding a Local Repository

    1. Create a Repository Configuration File:
    sudo nano /etc/yum.repos.d/localrepo.repo
    1. Add Repository Information:
    [localrepo]
    name=Local Repository
    baseurl=file:///mnt/localrepo
    enabled=1
    gpgcheck=0
    1. Save and Exit.

    Enabling and Disabling Repositories

    1. Enable a Repository:
    sudo yum-config-manager --enable <repo_id>

    or

    sudo dnf config-manager --set-enabled <repo_id>

    Example:

    sudo yum-config-manager --enable rhel-8-for-x86_64-appstream
    1. Disable a Repository:
    sudo yum-config-manager --disable <repo_id>

    or

    sudo dnf config-manager --set-disabled <repo_id>

    Example:

    sudo yum-config-manager --disable rhel-8-for-x86_64-appstream

    Practical Examples

    Example 1: Install and Update Packages from RHN

    1. Install the Apache HTTP Server:
    sudo yum install httpd
    1. Update the Apache HTTP Server:
    sudo yum update httpd
    1. Remove the Apache HTTP Server:
    sudo yum remove httpd

    Example 2: Install a Package from a Local RPM File

    1. Download the RPM File:
    wget http://example.com/packages/vim-enhanced-8.0.1763-15.el8.x86_64.rpm -P /tmp
    1. Install the RPM File:
    sudo yum install /tmp/vim-enhanced-8.0.1763-15.el8.x86_64.rpm

    Example 3: Configure a Remote Repository

    1. Create a Repository Configuration File:
    sudo nano /etc/yum.repos.d/myrepo.repo
    1. Add Repository Information:
    2. Save and Exit.
    [myrepo]
    name=My Custom Repository
    baseurl=http://myrepo.example.com/repo
    enabled=1
    gpgcheck=1
    gpgkey=http://myrepo.example.com/repo/RPM-GPG-KEY-myrepo
    1. Install a Package from the Custom Repository:
    sudo yum install mypackage

    Example 4: Configure a Local Repository

    • Mount the Local Repository:
    sudo mount /dev/sr0 /mnt/localrepo
    • Create a Repository Configuration File:
    sudo nano /etc/yum.repos.d/localrepo.repo
    • Add Repository Information:
    [localrepo]
    name=Local Repository
    baseurl=file:///mnt/localrepo
    enabled=1
    gpgcheck=0
    1. Save and Exit.
    2. Install a Package from the Local Repository:
    sudo yum install mylocalpackage

    Additional Tips

    • Clean the Yum/DNF Cache:Use the yum clean all or dnf clean all command to clean the package cache.
    sudo yum clean all
    # or
    sudo dnf clean all
    • List Installed Packages:Use the yum list installed or dnf list installed command to list all installed packages.
    yum list installed
    # or
    dnf list installed
    • Search for Packages:Use the yum search <keyword> or dnf search <keyword> command to search for packages.
    yum search httpd
    # or
    dnf search httpd
    • Get Package Information:Use the yum info <package_name> or dnf info <package_name> command to get detailed information about a package.
    yum info httpd
    # or
    dnf info httpd

    Conclusion

    Installing and updating software packages from Red Hat Network, a remote repository, or the local file system is essential for managing software on RHEL systems. Mastery of these tasks ensures that systems are kept up-to-date and secure, which is crucial for the RHCSA exam.


    These notes should help you understand how to install and update software packages from Red Hat Network, a remote repository, or from the local file system for the RHCSA exam.

    06.6 – Modify the system bootloader

    Overview

    The system bootloader is responsible for loading the operating system kernel and initializing the system. In RHEL, GRUB2 (GRand Unified Bootloader version 2) is the default bootloader. This guide covers how to modify GRUB2 settings, including changing the default boot entry, setting kernel parameters, and managing the GRUB2 configuration.


    GRUB2 Configuration Files

    • Main Configuration File/etc/default/grub
    • Custom Configuration Files/etc/grub.d/
    • GRUB2 Environment Block/boot/grub2/grubenv

    Viewing the Current GRUB2 Configuration

    To view the current GRUB2 configuration, you can use the grub2-editenv command:

    sudo grub2-editenv list

    Sample Output:

    saved_entry=0


    Modifying GRUB2 Settings

    Step 1: Edit the Main Configuration File

    The main configuration file for GRUB2 is /etc/default/grub. Open this file in a text editor to make changes.

    sudo nano /etc/default/grub

    Step 2: Common Modifications

    Change the Default Boot Entry

    To change the default boot entry, modify the GRUB_DEFAULT parameter. You can set it to a specific menu entry (starting from 0) or to the name of the menu entry.

    Example: Set the default boot entry to the second menu entry (index 1):

    GRUB_DEFAULT=1

    Example: Set the default boot entry to a specific kernel version:

    GRUB_DEFAULT="Advanced options for RHEL>RHEL, with Linux 4.18.0-240.el8.x86_64"

    Set the GRUB Timeout

    To set the timeout for the GRUB menu, modify the GRUB_TIMEOUT parameter. This value is in seconds.

    Example: Set the GRUB timeout to 5 seconds:

    GRUB_TIMEOUT=5

    Add Kernel Parameters

    To add kernel parameters, modify the GRUB_CMDLINE_LINUX parameter.

    Example: Add the rhgb and quiet parameters:

    GRUB_CMDLINE_LINUX="rhgb quiet"

    Step 3: Generate the GRUB2 Configuration

    After making changes to /etc/default/grub, generate the GRUB2 configuration file using the grub2-mkconfig command.

    For BIOS Systems

    sudo grub2-mkconfig -o /boot/grub2/grub.cfg

    For UEFI Systems

    sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

    Step 4: Reboot the System

    Reboot the system to apply the changes.

    sudo reboot

    Practical Examples

    Example 1: Change the Default Boot Entry

    1. Edit the Main Configuration File:
    sudo nano /etc/default/grub
    • Set the Default Boot Entry to the Second Menu Entry:
    GRUB_DEFAULT=1
    • Generate the GRUB2 Configuration:
    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    • Reboot the System:
    sudo reboot

    Example 2: Set the GRUB Timeout

    • Edit the Main Configuration File:
    sudo nano /etc/default/grub
    • Set the GRUB Timeout to 10 Seconds:
    GRUB_TIMEOUT=10
    • Generate the GRUB2 Configuration:
    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    • Reboot the System:
    sudo reboot

    Example 3: Add Kernel Parameters

    • Edit the Main Configuration File:
    sudo nano /etc/default/grub
    • Add the rhgb and quiet Kernel Parameters:
    GRUB_CMDLINE_LINUX="rhgb quiet"
    • Generate the GRUB2 Configuration:
    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    • Reboot the System:
    sudo reboot

    Additional Tips

    • List Available Boot Entries:Use the awk command to list available boot entries from the GRUB configuration file.
    awk -F\' '/menuentry / {print $2}' /boot/grub2/grub.cfg
    • Set a Persistent Default Boot Entry:Use the grub2-set-default command to set a persistent default boot entry.
    sudo grub2-set-default 1
    • Boot into Rescue Mode:Add the systemd.unit=rescue.target parameter to the kernel command line.
    GRUB_CMDLINE_LINUX="systemd.unit=rescue.target"
    • Boot into Emergency Mode:Add the systemd.unit=emergency.target parameter to the kernel command line.
    GRUB_CMDLINE_LINUX="systemd.unit=emergency.target"
    • Rebuild the GRUB2 Environment Block:Use the grub2-editenv command to rebuild the GRUB2 environment block.
    sudo grub2-editenv /boot/grub2/grubenv create

    Conclusion

    Modifying the system bootloader is essential for controlling the boot process and configuring system behavior at startup. Mastery of these tasks ensures that the system boots correctly and efficiently, which is crucial for the RHCSA exam.


    These notes should help you understand how to modify the system bootloader for the RHCSA exam.


    Discover more from Altgr Blog

    Subscribe to get the latest posts sent to your email.

    Leave a Reply

    Your email address will not be published. Required fields are marked *