Files
it-knowledge/src/rhcsa.md
T
2025-02-15 17:09:05 -06:00

7.8 KiB

RHCSA Study Notes

Exam Information

  • Exam Code: EX200
  • Duration: 2.5 hours
  • Passing Score: 210/300 (70%)

CLI Commands

Core Topics

1. Essential Tools

  • Access a shell prompt and issue commands
  • Use input-output redirection
  • Use grep and regular expressions
  • Access remote systems using SSH
  • Log in and switch users in multiuser targets

2. File Management

  • Create, delete, copy, and move files and directories
  • Create and manage hard and soft links
  • Find files and directories
  • Manage file permissions and ownership

3. Service Configuration

  • Configure networking and hostname resolution
  • Start, stop, and check system service status
  • Configure services to start automatically at boot
  • Configure time service clients

4. Storage Management

  • List, create, delete, and modify physical storage partitions
  • Create and configure filesystem
  • Configure and manage swap space
  • Create and manage LVM storage
  • Create and manage STRATIS storage

5. Container Management

  • Find and retrieve container images
  • Create and manage containers
  • Configure container storage

6. System Management

  • Boot, reboot, and shut down a system
  • Install Red Hat Enterprise Linux
  • Use systemd targets for system management
  • Configure system logging
  • Schedule tasks using cron and systemd timers

7. Security

  • Configure firewall settings
  • Configure SELinux
  • Manage users and groups
  • Set file permissions and ownership

Resources

  • Official Red Hat Documentation
  • Practice Environments
  • Useful Commands Reference

Progress Tracking

  • Complete practice exams
  • Lab environment setup
  • Hands-on practice completed

Note: Check boxes can be used to track progress on each topic as you study



CLI Commands

Networking

nmtui

nmtui # Network Manager Text User Interface

ip

sudo ip addr add dev eth0 192.168.2.2/24 # Add an IP address to the interface eth0 Note: Not persistent, will be lost on reboot

nmcli

nmcli connection add connection.interface-name ens160 ipv4.addresses 192.168.100.1/24 ipv4.gateway 192.168.100.254 type ethernet # Persistant IP address

sudo nmcli connection up ethernet-ens160 # Bring up the ethernet interface

sudo nmcli connection down ethernet-ens160 # Bring down the ethernet interface

sudo nmcli connection delete id "ens160" # Delete the ethernet connection

sudo nmcli connection show # Show all connections

Manage and Monitor Processes

top

top # Display running processes

top -o %MEM # Sort by memory usage

top -o %CPU # Sort by CPU usage

top -p 1234 # Display information for process 1234

pidof

pidof sleep # Display the PID of the sleep command

kill

kill -l # List all signals

kill -9 1234 # Kill the process with PID 1234

nice

nice -n 10 sleep 100 # Run the sleep command with a priority of 10

Partitions and Mounting

lsblk

lsblk -f # List all block devices with filesystem type

fdisk

sudo fdisk /dev/sda # Partition the disk /dev/sda 
# Note: n for new partition, p for primary, 1 for first partition, w for write

mkfs

sudo mkfs.xfs /dev/sda1 # Format the partition /dev/sda1 as XFS

mount

sudo mount /dev/sda1 /mnt # Mount the partition /dev/sda1 to /mnt

sudo mount -a # Mount all partitions

LVM

sudo fdisk /dev/sda # Partition the disk /dev/sda
# Note: p for print, n for new partition, t for type, 8e for LVM, w for write

### Physical Volumes ###
sudo pvdisplay # Display all physical volumes
sudo pvs # Display all physical volumes

sudo pvcreate /dev/sda1p1 # Create a physical volume on /dev/sda1p1
sudo pvcreate /dev/sdb1p1 # Create a physical volume on /dev/sdb1p1
sudo pvcreate /dev/sdc1p1 # Create a physical volume on /dev/sdc1p1

### Volume Groups ###
sudo vgcreate vg_data /dev/sda1p1 /dev/sdb1p1 /dev/sdc1p1 # Create a volume group vg_data on /dev/sda1p1, /dev/sdb1p1, /dev/sdc1p1

sudo vgdisplay # Display all volume groups
sudo vgs # Display all volume groups

### Logical Volumes ###
sudo lvdisplay # Display all logical volumes
sudo lvs # Display all logical volumes

sudo lvcreate -n lv_data -l 100%FREE vg_data # Create a logical volume lv_data on vg_data
sudo lvcreate -n lv_data -L 100M vg_data # Create a logical volume lv_data on vg_data with a size of 100M

### Formatting and Mounting ###
sudo mkfs.xfs /dev/vg_data/lv_data # Format the logical volume lv_data as XFS
sudo mount /dev/vg_data/lv_data /mnt # Mount the logical volume lv_data to /mnt
sudo umount /mnt # Unmount the logical volume lv_data from /mnt

### Extending and Reducing ###
sudo lvextend -L +100M /dev/vg_data/lv_data # Extend the logical volume lv_data by 100M
sudo lvreduce -L -100M /dev/vg_data/lv_data # Reduce the logical volume lv_data by 100M

sudo lvremove /dev/vg_data/lv_data # Remove the logical volume lv_data
sudo vgremove vg_data # Remove the volume group vg_data
sudo pvremove /dev/sda1p1 /dev/sdb1p1 /dev/sdc1p1 # Remove the physical volumes /dev/sda1p1, /dev/sdb1p1, /dev/sdc1p1

### Interactive LVM Tool ###
sudo lvm # Interactive LVM tool

STRATIS

sudo dnf install stratisd stratis-cli # Install the STRATIS storage service and CLI

sudo stratis pool create pool1 /dev/sda1p1 # Create a pool named pool1 on /dev/sda1p1
sudo stratis pool add-data pool1 /dev/sdb1p1 # Add a data volume to the pool named pool1 on /dev/sdb1p1

sudo stratis pool delete pool1 # Delete the pool named pool1

sudo stratis pool list # List all pools
sudo stratis blockdev list # List all block devices

sudo stratis fs create pool1 fstest # Create a filesystem named fstest on the pool named pool1
sudo stratis fs list # List all filesystems # Note: UUID is the UUID of the filesystem
mkdir /mnt/fsmount # Create a mount point for the filesystem
sudo nano /etc/fstab # Add the following line to the fstab file: UUID=1234567890 /mnt/fsmount xfs x-systemd.requires=stratisd.service 0 0
sudo mount -a # Mount all filesystems

Automatic Services & Task Scheduling

cron

sudo crontab -e # Edit the cron table

sudo crontab -l # List the cron table

### crontab format ###

* * * * * command # Run the command every minute

0 12 * * * command # Run the command at 12:00 PM

0 0 * * * command # Run the command at 12:00 AM

at

at 12:00 PM # Schedule a command to run at 12:00 PM

at -l # List all scheduled jobs

atq # List all scheduled jobs

atrm 1 # Remove the scheduled job with ID 1

systemd

sudo systemctl start sshd # Start the sshd service
sudo systemctl stop sshd # Stop the sshd service
sudo systemctl restart sshd # Restart the sshd service

sudo systemctl enable sshd # Enable the sshd service to start on boot
sudo systemctl disable sshd # Disable the sshd service from starting on boot
sudo systemctl status sshd # Check the status of the sshd service

sudo systemctl daemon-reload # Reload the systemd daemon

sudo systemctl mask sshd # Mask the sshd service
sudo systemctl unmask sshd # Unmask the sshd service

systemd service and timer commands

### Creating a service ###
sudo nano /etc/systemd/system/myapp.service
# [Unit]
# Description=My App

# [Service]
# Type=simple
# ExecStart=/usr/bin/myapp
# User=myuser

### Creating a timer ###
sudo nano /etc/systemd/system/myapp.timer
# [Unit]
# Description=My App Timer

# [Timer]
# OnBootSec=10min # Run the timer 10 minutes after the system starts
# OnCalendar=*-*-* 10:00:00 # Run at 10:00 AM every day
# OnCalendar=*-*-* *:*:0 # Run at every minute

# [Install]
# WantedBy=graphical.target # Run the timer on the graphical target

### Tying the timer to the service ###
sudo systemctl link /etc/systemd/system/myapp.timer 

### Starting a service ###
sudo systemctl start myapp
sudo systemctl start myapp.timer