(RHCSA) Operate Running 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:

“OPERATE RUNNING 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:

BOOT, REBOOT, AND SHUT DOWN A SYSTEM NORMALLY
BOOT SYSTEMS INTO DIFFERENT TARGETS MANUALLY
INTERRUPT THE BOOT PROCESS IN ORDER TO GAIN ACCESS TO A SYSTEM
IDENTIFY CPU/MEMORY INTENSIVE PROCESSES AND KILL PROCESSES
ADJUST PROCESS SCHEDULING
MANAGE TUNING PROFILES
LOCATE AND INTERPRET SYSTEM LOG FILES AND JOURNALS
PRESERVE SYSTEM JOURNALS
START, STOP, AND CHECK THE STATUS OF NETWORK SERVICES
SECURELY TRANSFER FILES BETWEEN SYSTEMS

šŸ“‘ Cheatsheet:

BOOT, REBOOT, AND SHUT DOWN A SYSTEM NORMALLY
  • systemctl reboot āž” shut down and reboot the system.

  • systemctl halt āž” shut down and halt the system (stops CPU but keeps it powered).

  • systemctl poweroff āž” shut down and poweroff the system (stops CPU and turns off the power).

BOOT SYSTEMS INTO DIFFERENT TARGETS MANUALLY
  • systemctl get-default āž” get the default boot target.

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

  • systemctl --type target --all āž” list all target units (loaded or not).

  • Interrupt boot process to temporarily boot from another target (i.e.: multi.user.target), without changing the default target:

    • append systemd.unit=multi-user.target āž” to the end of the boot cmd, when editing the grub menu entry, and start it with Ctrl+x.
INTERRUPT THE BOOT PROCESS IN ORDER TO GAIN ACCESS TO A SYSTEM
  • Reset root pwd in 7 steps:

    • append rd.break āž” to the end of the boot cmd, when editing the grub menu entry, and start it with Ctrl+x.

    • chroot /sysroot āž” make the mounted (read-only) root file system (/sysroot) appear as mounted on /.

    • mount -o remount,rw / āž” remount root file system in read/write mode for the passwd cmd to be able to modify the shadow file with a new pwd.

    • passwd āž” change password for the root user.

    • touch .autorelabel āž” create .autorelabel file to instruct the OS to run SELinux relabeling on all files on the next reboot (including the shadow that was updated).

    • exit āž” the chroot shell.

    • reboot āž” the system.

    • Extra Step: mandb āž” after restart, rebuild manual pages db.

  • Install most recent kernel, without removing/updating previous kernel (7 files):

    • linux-firmware
    • kernel
    • kernel-core
    • kernel-headers
    • kernel-modules
    • kernel-tools
    • kernel-tools-libs
  • dnf list installed kernel* āž” list installed kernels.

  • cat /boot/grub2/grubenv āž” check if new installed kernel is default boot option.

IDENTIFY CPU/MEMORY INTENSIVE PROCESSES AND KILL PROCESSES
  • tar -czf home.tar.gz . & āž” start tar as background process in the current shell.

  • jobs āž” list backgrund processes in the current shell.

  • ps -aux āž” list every process in the system.

  • ps -eo pid,nice,cmd | grep top āž” show pid and nice for the top āž” running process.

  • kill -sigstop 3251 āž” send stop signal to process.

ADJUST PROCESS SCHEDULING
  • nice -n +8 top āž” run top cmd with a lower priority (by 8).

  • renice -n -10 -p 3261 āž” increase the priority of the 3261 running proccess to -10.

  • crontab -e āž” edit user crontab.

  • 23 8 * * * echo "Hello World" > /dev/pts/0 āž” in a crontab file, this entry will make the terminal /dev/pts/0 print the message everyday at 8:23.

  • cat /var/log/cron āž” cron execution logs.

MANAGE TUNING PROFILES
  • tuned-adm profile, tuned-adm listāž” list all available system tuning profiles.

  • tuned-adm active āž” show current system tuning profile.

  • tuned-adm recommend āž” list recommended system tuning profile.

  • tuned-adm profile balanced āž” set system profile to balanced.

LOCATE AND INTERPRET SYSTEM LOG FILES AND JOURNALS
  • cat /etc/rsyslog.conf āž” see directories defined to save the log files generated by rsyslog.

  • tail -f /var/log/secure āž” live view of the secure log file.

  • tail /var/log/audit/audit.log āž” view SELinux related logs.

  • journalctl --since 10:00 āž” view journal logs from 10:00 until now.

  • journalctl --unit sshd.service -o verbose āž” view journal logs related to sshd.service displaying additional parameters.

  • journalctl --priority crit āž” view critial priority logs.

  • logger "$LOGNAME is delivering this message at $(date)" āž” write custom log message to /var/log/messages.

PRESERVE SYSTEM JOURNALS
  • Preserve system journals:

    • mkdir -p /var/log/journal
    • systemctl restart systemd-journald
  • journalctl -b -1 āž” view log messages from previous boot.

  • item āž” description.

START, STOP, AND CHECK THE STATUS OF NETWORK SERVICES
  • systemctl status sshd.service āž” verify if sshd general status.

  • systemctl enable sshd.service āž” make sshd start at system startup.

  • systemctl disable sshd.service āž” make sshd do not start at system startup.

  • systemctl start sshd.service āž” make sshd start temporarily (this system do not persist reboots).

  • systemctl disable sshd.service āž” make sshd stop temporarily (this setting do not persist reboots).

SECURELY TRANSFER FILES BETWEEN SYSTEMS
  • scp srv2:/etc/chrony.conf /tmp āž” get file from srv2.

  • scp -r /etc/sysconfig srv2:/tmp āž” transfer entire directory to srv2.

  • scp -p file1.txt srv2:/tmp āž” transfer file to srv2 /tmp directory preserving file attributes (permissions, etc).


Next:

(RHCSA) Configure Local Storage

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