(RHCSA) Deploy, Configure, and Maintain Systems

This is part of the RHCSA Exam Study Guide series

image

This is part of the independent and unofficial RHCSA Exam Study Guide series providing free šŸ¤‘ resources to prepare for the exam.

This post covers the objectives under the section:

“DEPLOY, CONFIGURE, AND MAINTAIN SYSTEMS”

It contains two main parts:

  • Resources: with links to learn and practice for each objective.
  • Cheatsheet: containing some examples of commands and actions performed in each objective (when applied).

šŸ“š Resources:

SCHEDULE TASKS USING AT AND CRON
START AND STOP SERVICES AND CONFIGURE SERVICES TO START AUTOMATICALLY AT BOOT
CONFIGURE SYSTEMS TO BOOT INTO A SPECIFIC TARGET AUTOMATICALLY
CONFIGURE TIME SERVICE CLIENTS
INSTALL AND UPDATE SOFTWARE PACKAGES FROM RED HAT NETWORK, A REMOTE REPOSITORY, OR FROM THE LOCAL FILE SYSTEM

Attention: Before starting, it is recommended to set up a local repository using the Red Hat Enterprise Linux 8 installation ISO file:

  • Add the RHEL 8 iso file as an image to Virtual Box (similar process to the virtualization tool of your choice):

  • Mount locally a repository from the ISO image:

    • mount -o ro /dev/sr0 /mnt āž” mount iso image to /mnt drive (find the device name if not /dev/sr0).

    • /dev/sr0 /mnt iso9660 ro 0 0 āž” on /etc/fstab/, mounts the iso image at system startup.

    • create /etc/yum.repos.d/local.repo file āž” to install a local repository.

      [BaseOS]
      name=BaseOS
      baseurl=file:///mnt/BaseOS
      gpgcheck=0
      enabled=1
      
      [AppStream]
      name=AppStream
      baseurl=file:///mnt/AppStream
      gpgcheck=0
      enabled=1
      

Done!

WORK WITH PACKAGE MODULE STREAMS
MODIFY THE SYSTEM BOOTLOADER

šŸ“‘ Cheatsheet:

SCHEDULE TASKS USING AT AND CRON
  • See examples and references at man crontab and man -s 5 crontab, also, see the cheatsheet at /etc/crontab file.

  • Add 0 */2 * * mon-fri user1 backup.sh to /etc/crontab file āž” run backup.sh shell script as user1 every 2nd hour at minute 0, every day-of-week.

  • crontab -e āž” open current user’s crontab file (no need to specify user for the cron job, file will be saved as /var/spool/cron/user1).

  • Create /etc/crond.d/verify-backup file āž” cron will read and run the jobs as specified in the file.

    # Run verify-backup.sh script everyday, twice a day.
    0 */12 * * * user1 verify-backup.sh
    
  • Add user2 to /etc/cron.deny file āž” to block crontab access for user2.

  • Schedule a one time task using at:

    • at now + 5 hours āž” start at prompt, deliberating the time to run.
    • Type echo "task completed by at >> /tmp/at-test.txt" āž” to define a test task.
    • Press CTRL + d āž” to exit the at prompt.
  • atq āž” lists the user’s pending job.

  • at -c 4 āž” cat job 4 to standard output.

  • atrm 4 āž” removes job 4 from the queue.

  • cat /var/log/cron āž” verify the log file for cron and at.

  • Add 7 5 remove_obsolete_pkgs dnf autoremove to /etc/anacrontab file āž” once a week, run dnf autoremove, delaying 5 mins to begin.

  • anacron āž” manually run all jobs scheduled in /etc/anacrontab.

  • Each entry in /etc/anacrontab generates a file in /var/spool/anacron with it’s execution date.

  • journalctl -g anacron āž” check logs for the word anacron.

START AND STOP SERVICES AND CONFIGURE SERVICES TO START AUTOMATICALLY AT BOOT
  • systemctl āž” shows loaded units.

  • systemctl list-unit-files āž” lists unit files.

  • systemctl list-units āž” lists active units.

  • systemctl --failed āž” list all units that failed to start last system boot.

  • systemctl start firewalld āž” starts firewalld service.

  • systemctl --user start mycustom.service āž” starts mycustom.service unit file, stored at ~/.config/systemd/user/, as current user.

  • systemctl restart firewalld āž” restarts firewalld service.

  • systemctl stop firewalld āž” stops firewalld service.

  • systemctl enable firewalld āž” enable firewalld service to start at system boot.

  • systemctl disable firewalld āž” disable firewalld service, it won’t start at system boot.

  • systemctl status firewalld āž” check firewalld service status.

  • systemctl show firewalld āž” show firewalld unit details.

  • systemctl is-enabled firewalld āž” check if firewalld service is enabled.

  • systemctl daemon-reload āž” reload the systemd manager configuration.

  • systemctl mask firewalld āž” prohibit firewalld from being enabled or disabled.

CONFIGURE SYSTEMS TO BOOT INTO A SPECIFIC TARGET AUTOMATICALLY
  • systemctl get-default āž” displays the current default target.

  • systemctl isolate multi-user.target āž” switch to multi-user.target.

  • systemctl set-default multi-user āž” set multi-user.target as default.

  • systemctl -t target --all āž” lists all units of type target.

  • systemctl reboot āž” reboot the system.

CONFIGURE TIME SERVICE CLIENTS
  • date, timedatectl āž” check current system date and time.

  • timedatectl set-ntp false āž” disable networking time sync, also disables chronyd.service if enabled.

  • timedatectl set-time "2021-07-08 04:30:00 āž” change date and time.

  • date --set 04:00 āž” change time.

  • tzselect āž” starts the helper to set timezone.

  • systemctl status chronyd āž” (requires chrony) check if Chrony is active, it is the preferred implementation of the Network Time Protocol.

  • Bind chronyd to a different server:

    • chronyc sources āž” checks current time sources chronyd is accessing.
    • On /etc/chrony.conf, comment all entries beggining with pool or server.
    • Add a new line in the end: server 127.127.1.0
    • Add a new line in the end: server 127.127.1.4 iburst prefer (Check man chrony.config to learn the directives allowed.)
    • systemctl restart chronyd āž” apply changes.
    • chronyc sources āž” checks current time sources chronyd is accessing.
INSTALL AND UPDATE SOFTWARE PACKAGES FROM RED HAT NETWORK, A REMOTE REPOSITORY, OR FROM THE LOCAL FILE SYSTEM
  • To add a repository from an iso image:

    • mount -o ro /dev/sr0 /mnt āž” mount iso image to /mnt drive.

    • /dev/sr0 /mnt iso9660 ro 0 0 āž” on /etc/fstab/, mounts the iso image at system startup.

    • create /etc/yum.repos.d/local.repo file āž” to install a local repository.

      [BaseOS]
      name=BaseOS
      baseurl=file:///mnt/BaseOS
      gpgcheck=0
      
  • Check man -s 5 yum.conf for directives and options for a .repo file, and cat /etc/dnf/dnf.conf to see an example of the syntax.

Using rpm
  • rpm -i ./zsh-5.5.1-6.el8_1.2.x86_64.rpm āž” install package file from current dir.

  • rpm -i --reinstall -vh /zsh-5.5.1-6.el8_1.2.x86_64.rpm āž” reinstall package from file (verbose mode, show progress printing a hash bar).

  • rpm -qi zsh āž” show package info (from installed package).

  • rpm -qa | grep zsh āž” query all packages and grep the word zsh.

  • rpm -qip ./zsh-5.1.1-6.el8_1.2.x86_64.rpm āž” show package file info (from the repository).

  • rpm -K ./zsh-5.5.1-6.el8_1.2.x86_64.rpm --nosignature āž” validate integrity (completeness and error-free state) and authententicity for the given package file.

  • rpm -V zsh āž” check installed package file attributes compared to the package file present on the repository (permission mode, size, owner, group, etc…), if no output, integrity of attributes are OK.

  • rpm -q zsh āž” check whether zsh package is installed.

  • rpm -qf /etc/hosts āž” search what package provides the file /etc/hosts (similar to dnf provides /etc/hosts).

  • rpm -qc zsh āž” list all configuration files for zsh.

Using dnf/yum
  • dnf repolist āž” show installed repositories.

  • dnf repolist --all āž” show all repositories dnf is aware of (enabled or disabled).

  • dnf search tmux āž” search in packages containing the worf tmux in it’si name or metadadata.

  • dnf config-manager --disable BaseOS āž” disable BaseOS repository.

  • dnf config-manager --enable BaseOS āž” enable BaseOS repository.

  • dnf install tmux -y āž” install tmux package, assuming yes for all questions.

  • dnf list --installed āž” show installed packages.

  • dnf repoquery --repo "AppStream", dnf repository-packages BaseOS list āž” list all the packages available for a specific repository.

  • dnf provides /etc/group āž” show which package contains the /etc/group file.

  • tail /var/log/dnf.log āž” see recent interactions.

  • dnf repoquery --deplist policycoreutils āž” list dependencies for the given package.

  • dnf group list --installed āž” list only installed package groups.

  • dnf group install "Security Tools" āž” install package group.

WORK WITH PACKAGE MODULE STREAMS
  • dnf module list --installed āž” list only installed modules.

  • dnf module list perl* āž” list all the streams for all modules with name starting as perl.

  • dnf module list --enabled* āž” list all enabled module streams.

  • dnf module enable postgresql:9.6 āž” enable module on the specified stream.

  • dnf module update postgresql -y āž” update postgresql module.

  • dnf module install --profile postgresql:10 āž” install the module’s stream 10.

  • dnf module install --profile perl:5.26/minimal āž” install the module with minimal profile for the stream 5.26.

  • dnf module remove --profile postgresql:10 āž” uninstall the module’s stream 10.

  • dnf module info --profile postgresql āž” list all profiles available for the module.

  • dnf module info --profile postgresql:10 āž” show details for the specific module stream.

  • dnf module reset postgrelsql āž” reset module.

MODIFY THE SYSTEM BOOTLOADER
  • grubby --default-kernel āž” display the path of the default kernel.

  • grubby --default-index āž” display the index number of the default kernel.

  • grubby --set-default /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 āž” set specified kernel to default.

  • sudo grubby --set-default-index=1 āž” set specified kernel to default, by using it’s index number.

  • grubby --info=ALL āž” display information of all boot entries.

  • grubby --info /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 āž” display information of the specified kernel entry.

  • grubby --remove-args=quiet --update-kernel=DEFAULT āž” remove the quiet argument from the DEFAULT boot entry.

  • grubby --args=quiet --update-kernel=DEFAULT āž” add the quiet argument to the DEFAULT boot entry.

  • /etc/default/grub āž” edit this file to change grub params.

  • grub2-mkconfig -o /boot/grub2/grub.cfg, grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg āž” make the config file to apply changes.


Next:

(RHCSA) Manage Basic Networking

…or back to Red Hat Certified System Administrator (RHCSA) Exam Study Guide



Footnotes:

  • Follow me on Twitter to get more posts like this and other quick tips in your feed.
  • If you have any doubts or tips about this article, Iā€™d appreciate knowing and discussing it via email.
  • Do you have any other Linux tips? Would you like to publish that in this blog? Please send an email to all drops.
  • As English is not my native language, I apologize for the errors. Corrections are welcome.
  • Contact: contact [@] alldrops [.] info.

Read more on linux drops: