RHEL 8 Linux Cheat-Sheet & Troubleshooting Guide

This guide is tailored for RHEL 8 users, providing updated tools, commands, and troubleshooting techniques. It covers a wide range of topics, including boot processes, advanced networking, user administration, storage management, and more.


1. RHEL 8 Boot Process

  • MBR → GRUB (loads Kernel image → extracts initramfs) → Kernel (loads drivers from initrd → launches systemd) → SYSTEMD (reads /etc/systemd configs → follows /etc/systemd/system/default.target → reaches required target state).

2. Booting From the GRUB Prompt

  • Use the grub> commands to troubleshoot boot issues:
    grub> ls
    grub> ls (hd0,msdos2)
    grub> set root=(hd0,msdos1)
    grub> linux /vmlinuz-3.13.0-29-generic ro root=/dev/mapper/centos-root
    grub> initrd /initrd.img-3.13.0-29-generic
    grub> boot
    

3. Kernel-Panic Recovery

  • Regenerate the Initrd image:
    # mkinitrd /boot/initramfs-3.10.0-957.el7.x86_64.img 3.10.0-957.el7.x86_64
    # dracut -f /boot/initramfs-3.10.0-957.el7.x86_64.img 3.10.0-957.el7.x86_64
    

4. Boot-Time Diagnostics

  • Analyze boot performance:
    • systemd-analyze → overall boot time.
    • systemd-analyze blame → per-unit timing.

5. System Utilization & Diagnostics

  • Core tools for monitoring: topvmstatiostatdmesglsoffuserpmappssarstracewatchstress.

6. File Operations with find

  • Delete files:
    find / -type f -name tecmint.txt -exec rm -f {} ;
    find / -type f -perm 0777 -exec rm -f {} ;
    find / -type f -size +100M -exec rm -f {} ;
    
  • Move files:
    find /var/log -type f -name "*.log" -mtime +30 -exec mv {} /archive/logs/ ;
    find /tmp -type f -mtime +14 -exec mv -t /tmp/old {} +
    

7. Networking in RHEL 8

  • NetworkManager is the default controller. Use nmclinmtui, and ip commands.
  • Core operations:
    • Show interfaces: ip addrip link show.
    • Bring interface up/down: nmcli device disconnect ens33nmcli device connect ens33.
    • Create static address:
      nmcli con add type ethernet con-name static-ens33 ifname ens33 ip4 192.168.1.50/24 gw4 192.168.1.1
      nmcli con mod static-ens33 ipv4.dns "8.8.8.8 1.1.1.1"
      nmcli con up static-ens33
      
    • View routes: ip route.
    • Add temporary route: ip route add 10.10.0.0/24 via 192.168.1.254.

8. High-Availability with Pacemaker-Corosync

  • Install packages:
    yum install -y pcs pacemaker corosync resource-agents
    systemctl enable --now pcsd
    
  • Authenticate and create cluster:
    echo mypass | passwd --stdin hacluster
    pcs host auth node1 node2 -u hacluster -p mypass
    pcs cluster setup --name prod-cluster node1 node2
    pcs cluster start --all
    pcs cluster enable --all
    
  • Verify status: pcs statuspcs status corosyncpcs resource show.

9. User Administration

  • Configuration Files:
    • /etc/login.defs/etc/default/useradd/etc/skel/
    • Updates /etc/passwd/etc/group/etc/shadow/etc/gshadow.
  • Generate shadow only:
    /usr/sbin/pwconv
    
  • Examples:
    • /etc/passwd (7 fields):
      student1:x:501:501::/home/student1:/bin/bash
      
    • /etc/shadow (9 fields):
      student1:$1$XSFMv2ru$lfTACjN.XxaxbHA0EkB4U0:13891:0:99999:7:::
      
  • Create user with full options:
    useradd -u 9181361 -g 3100000 -G 3100004 -c "Vallabh Darole" -m a181361 ; echo pass@1234 | passwd --stdin a181361
    

10. Cron & Scheduling

  • Cron:
    • Example cron job:
      * * * * * /bin/bash echo hello
      
  • at Usage:
    yum install at ; systemctl status atd
    at -f data.sh now
    at -f data.sh 04:18
    atqu
    at -d <job#>
    at -f data.sh now + 1 hour
    

11. RPM Package Manager Quick Reference

  • Commands:
    rpm -qa
    rpm -qi nano
    rpm -qf /usr/bin/nano
    rpm -qpi <pkg>.rpm
    rpm -ql <pkg>
    rpm -ivh <pkg>.rpm
    rpm -Uvh <pkg>.rpm
    rpm -ev <pkg>.rpm
    rpm -ev --nodeps <pkg>.rpm
    

12. Disk & Storage Management

  • Commands:
    echo "1" > /sys/class/fc_host/host$i/issue_lip  
    echo "- - -" > /sys/class/scsi_host/host$i/scan
    echo 1 > /sys/block/sdX/device/delete
    
  • Restore deleted LV:
    vgcfgrestore vg01 -f /etc/lvm/archive/ ; lvchange -a y /dev/vg01/lv01
    
  • Storage migration:
    pvmove -v /dev/sdb2 /dev/sdb3
    
  • Move VG to new system:
    vgchange -an design ; vgexport design
    pvscan ; vgimport design ; vgchange -ay design ; mount /dev/design/users /mnt/design/users
    

13. Multipathing

  • Purpose: Provides multiple I/O paths between server ↔ storage for redundancy and load balancing.
  • Linux Native Multipathd:
    • Daemon: Consolidates device nodes under /dev/mapper/*.
    • Config file/etc/multipath.conf (blacklist, path selectors, policies, etc.).
    • Common Commands:
      multipath -ll              # List multipath devices/paths
      multipath -f <device>      # Flush/remove specific map
      
  • Dell EMC PowerPath:
    • Features: Tuned algorithms for EMC arrays, fast failover/failback, advanced load balancing.
    • Common Commands:
      powermt display dev=all
      powermt display paths
      

14. Sticky-Bit Permission

  • Purpose: Inside a world-writable directory, only the file owner (or root) may delete/rename their files (e.g., /tmp).
  • Permission String Exampledrwxrwxrwt (note the trailing t).
  • Commands:
    chmod +t /dir    # Set sticky bit
    chmod -t /dir    # Remove sticky bit
    

15. NFS Quick Reference

  • Export Example:
    /etc/exports example /nfs1 192.168.75.10(rw)
    
  • Client Mount:
    mount -t nfs 192.168.75.199:/nfs1 /nfs1
    
  • FSTAB Entry:
    nfs-server:/export/share /mnt/share nfs rw,soft,timeo=10,retrans=3 0 0
    

16. Joining RHEL to Active Directory

  • Installation:
    yum install sssd realmd oddjob oddjob-mkhomedir adcli samba-common samba-common-tools krb5-workstation openldap-clients policycoreutils-python
    
  • Join Command:
    realm join --user=<domain_user> <domain_name>
    realm list
    cat /etc/sssd/sssd.conf

No comments:

Post a Comment