Chapter 11: Control Services and Boot Process

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

systemctl --failed --type=service

To list all the failed units

systemctl reload-or-restart <service>

will attempt to reload a service, but if the service does not support reloading, it will restart the service. Restart will change the PID, reload will not.

To access that root shell

• Reboot the system. • Interrupt the boot-loader countdown by pressing any key, except Enter. • Move the cursor to the rescue kernel entry to boot (the one with the word rescue in its name). • Press e to edit the selected entry. • Move the cursor to the kernel command line (the line that starts with linux). • Append rd.break. With that option, the system breaks just before the system hands control from the initramfs to the actual system. • Press Ctrl+x to boot with the changes. • Press Enter to perform maintenance when prompted.

System Journals location

/run/log/journal To store journals in the /var/log/journal directory, which persists across reboots, set the Storage parameter to persistent in /etc/systemd/journald.conf and systemctl restart systemd-journald.service to apply the changes.

systemctl isolate <target>

switch to a different target. Isolating a target stops all services not required by that target (and its dependencies), and starts any required services not yet started. You can only isolate targets that have AllowIsolate=yes set in their unit files. e.g systemctl cat graphical.target

/etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg

can be edited to change the grub boot timeout. 2nd command is used to update the grub config, tack o sends it to the grub.cfg

systemctl list-units --all

lists all service units regardless of the activation states

systemctl get-default

display the default target called by the system

Boot into emergency mode

Append the systemd.unit=emergency.target string to the end of the Linux line of the default boot loader entry

systemctl mask <unit> / systemctl unmask <unit>

Masking a service prevents an administrator from accidentally starting a service that conflicts with others. Masking creates a link in the configuration directories to the /dev/null file which prevents the service from starting.

systemctl list-unit-files --type=service

To see every available unit file within the systemd paths, including those that systemd has not attempted to load

systemctl set-default <target>

To set a default target unit

systemctl is-enabled sshd.service

To verify whether a service unit is enabled to start automatically during system boot

systemctl is-failed sshd.service

To verify whether the unit failed during startup

systemd.unit=<target>

add this to the end of the Linux line in the boot menu to boot into a specific target. E.g. multi-user/rescue/emergency.target. crtl+x to continue

rd.break

pauses the boot process to enter a shell in the ram-disk environment to access /sysroot

systemctl list-units --type=service

the --type=service option limits the type of systemd units to active service units

pidof <service>

to see all of the process ids associated to a service. The lowest PID is the main process ID

systemctl is-active sshd.service

to verify whether a service unit is active (running)

systemctl list-dependencies <unit> --reverse

will display what calls the service. Typically a .target.

systemctl list-dependencies <unit>

will list all dependencies required for a unit to work

Repair File System Issues at Boot

• Enter emergency boot - systemd.unit=emergency.target • List file systems systemd monuts - mount • Locate the broken file system, likely listed as read-only • Remount the broken file system in read/write mode - mount -o remount,rw <filesys> • Mount all file systems - mount -a • correct issues with (vim) /etc/fstab • Reload the systemd daemon for the system to register the new /etc/fstab - systemctl daemon-reload • mount -a • systemctl reboot

To reset the root password

• Remount /sysroot as read/write: mount -o remount,rw /sysroot • Switch into a chroot jail: chroot /sysroot • Set a new root password: passwd root • Relabel filesystem: touch /.autorelabel • Type exit twice. The first command exits the chroot jail, and the second command exits the initramfs debug shell.

Linux Boot Process

• The machine is powered on. The system firmware, either modern UEFI or older BIOS, runs a Power On Self Test (POST) and starts to initialize the hardware. • The system firmware searches for a bootable device, either configured in the UEFI boot firmware or by searching for a Master Boot Record (MBR) on all disks, in the order configured in the BIOS or UEFI. • The system firmware reads a boot loader from disk and then passes control of the system to the boot loader. On a Red Hat Enterprise Linux 9 system, the boot loader is the GRand Unified Bootloader version 2 (GRUB2). • GRUB2 loads its configuration from the /boot/grub2/grub.cfg file for BIOS and from the /boot/efi/EFI/redhat/grub.cfg file for UEFI, and displays a menu where you can select which kernel to boot. • After you select a kernel, or the timeout expires, the boot loader loads the kernel and initramfs from disk and places them in memory. An initramfs is an archive containing the kernel modules for all the hardware required at boot, initialization scripts, and more. On Red Hat Enterprise Linux 9, the initramfs contains an entire usable system by itself. • The boot loader hands control over to the kernel, passing in any options specified on the kernel command line in the boot loader, and the location of the initramfs in memory. • The kernel initializes all hardware for which it can find a driver in the initramfs, then executes /sbin/init from the initramfs as PID 1. On Red Hat Enterprise Linux 9, /sbin/init is a link to systemd. • The systemd instance from the initramfs executes all units for the initrd.target target. This includes mounting the root file system on disk on to the /sysroot directory. • The kernel switches (pivots) the root file system from initramfs to the root file system in the /sysroot directory. systemd then re-executes itself by using the copy of systemd installed on the disk. • systemd looks for a default target, either passed in from the kernel command line or configured on the system, then starts (and stops) units to comply with the configuration for that target, solving dependencies between units automatically. In essence, a systemd target is a set of units that the system should activate to reach the desired state. These targets typically start a text-based login or a graphical login screen.

Update Grub Config

• cat /etc/default/grub - make edits • grub2-mkconfig -o /boot/grub2/grub.cfg - to load changes to grub


संबंधित स्टडी सेट्स

Pre Chapter 39: Drug Therapy for Constipation and Elimination Problems

View Set

Entrevista con Doña Vascuñana y La Emperadora

View Set

Chapter 4 Statistics Review test

View Set

BIO 1201 Chapter 8 Cell Reproduction

View Set

Chapter 27 Reproductive System A&P2 Final

View Set

2.04 Quiz: Voices of an Emerging Nation

View Set