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