(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: