| name | linux-rhel |
| description | Red Hat Enterprise Linux (RHEL 7/8/9) and compatible distros (CentOS, AlmaLinux, Rocky). Covers systemd (units/targets/journald), LVM (pvcreate/vgcreate/lvcreate/extend/migrate), SELinux (enforcing/permissive/audit2allow/semanage/restorecon), firewalld/iptables, nmcli/nmtui network configuration, bonding/teaming/VLANs, dnf/rpm/subscription-manager, kdump/crash analysis, performance tuning (perf/sar/vmstat/iostat/tuned), and RHEL security hardening (PAM/auditd/FIPS). Use for RHEL admin tasks, systemd troubleshooting, storage expansion, SELinux policy issues, and performance investigation. |
| metadata | {"author":"Ryan Loiselle","version":"1.0"} |
| compatibility | RHEL 7, 8, 9. CentOS 7. AlmaLinux 8/9. Rocky Linux 8/9. Amazon Linux 2 where noted. |
Linux RHEL Skill
Red Hat Enterprise Linux administration reference — RHEL 7/8/9 focus.
Ryan's context: Extensive RHEL experience across versions 7, 8, and 9.
Related skills:
systemd
Unit Management
systemctl status <unit>
systemctl start|stop|restart|reload <unit>
systemctl enable|disable <unit>
systemctl enable --now <unit>
systemctl is-active|is-enabled <unit>
systemctl list-units
systemctl list-units --failed
systemctl list-unit-files
systemctl list-dependencies <unit>
systemctl daemon-reload
Unit File Locations
| Path | Purpose |
|---|
/usr/lib/systemd/system/ | Package-installed units (do not edit) |
/etc/systemd/system/ | Admin overrides and custom units |
/run/systemd/system/ | Runtime units (transient) |
systemctl edit <unit>
systemctl edit --full <unit>
cat > /etc/systemd/system/myapp.service <<'EOF'
[Unit]
Description=My Application
After=network-online.target
[Service]
Type=simple
User=myapp
ExecStart=/opt/myapp/bin/myapp --config /etc/myapp/config.yaml
Restart=on-failure
RestartSec=5s
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && systemctl enable --now myapp
journalctl
journalctl -xe
journalctl -u <unit>
journalctl -u <unit> -f
journalctl -u <unit> --since "1 hour ago"
journalctl -u <unit> --since "2024-01-01" --until "2024-01-02"
journalctl -p err -b
journalctl -b -1
journalctl --disk-usage
journalctl --vacuum-size=500M
journalctl --vacuum-time=30d
Targets (runlevels)
| Target | Equivalent | Use |
|---|
poweroff.target | runlevel 0 | Halt |
rescue.target | runlevel 1 | Single user / rescue |
multi-user.target | runlevel 3 | Multi-user no GUI |
graphical.target | runlevel 5 | Multi-user with GUI |
reboot.target | runlevel 6 | Reboot |
emergency.target | — | Emergency shell (read-only root) |
systemctl get-default
systemctl set-default multi-user.target
systemctl isolate rescue.target
LVM — Logical Volume Manager
pvdisplay / pvs
vgdisplay / vgs
lvdisplay / lvs
lsblk -f
pvcreate /dev/sdb
vgcreate datavg /dev/sdb
lvcreate -n datalv -L 50G datavg
mkfs.xfs /dev/datavg/datalv
echo "/dev/datavg/datalv /data xfs defaults 0 0" >> /etc/fstab
mount /data
lvextend -L +20G /dev/datavg/datalv
lvextend -l +100%FREE /dev/datavg/datalv
xfs_growfs /data
resize2fs /dev/datavg/datalv
pvcreate /dev/sdc
vgextend datavg /dev/sdc
pvmove /dev/sdb
vgreduce datavg /dev/sdb
pvremove /dev/sdb
lvcreate -L 5G -s -n datalv-snap /dev/datavg/datalv
lvcreate -T -L 100G datavg/thinpool
lvcreate -V 200G -T datavg/thinpool -n thinlv1
SELinux
getenforce
setenforce 0
setenforce 1
ls -Z /path
ps -eZ
id -Z
ausearch -m avc -ts recent
ausearch -m avc -ts today | audit2why
ausearch -m avc -ts recent | audit2allow
audit2allow -M mymodule < avc.log
semodule -i mymodule.pp
restorecon -Rv /path
semanage fcontext -a -t httpd_sys_content_t "/myapp(/.*)?"
restorecon -Rv /myapp
getsebool -a | grep httpd
setsebool -P httpd_can_network_connect 1
semanage port -l | grep 8080
semanage port -a -t http_port_t -p tcp 8080
Networking with nmcli
nmcli general status
nmcli device status
nmcli connection show
nmcli connection modify eth0 ipv4.addresses 10.0.0.5/24
nmcli connection modify eth0 ipv4.gateway 10.0.0.1
nmcli connection modify eth0 ipv4.dns "8.8.8.8 8.8.4.4"
nmcli connection modify eth0 ipv4.method manual
nmcli connection modify eth0 ipv4.method auto
nmcli connection up eth0
nmcli connection add type ethernet ifname eth1 con-name office ipv4.method manual \
ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1
nmcli connection add type bond ifname bond0 bond.options "mode=active-backup"
nmcli connection add type ethernet ifname eth0 master bond0
nmcli connection add type ethernet ifname eth1 master bond0
nmcli connection add type bond ifname bond0 bond.options "mode=802.3ad,lacp_rate=fast"
nmcli connection add type vlan dev eth0 id 100 con-name vlan100 \
ipv4.method manual ipv4.addresses 10.1.100.5/24
ip addr show
ip route show
ss -tulnp
firewalld
firewall-cmd --get-default-zone
firewall-cmd --list-all
firewall-cmd --list-all --zone=public
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-port=8443/tcp
firewall-cmd --permanent --remove-port=8080/tcp
firewall-cmd --reload
firewall-cmd --permanent --add-rich-rule=\
'rule family="ipv4" source address="10.0.0.0/8" service name="ssh" accept'
firewall-cmd --direct --add-rule ipv4 filter INPUT 0 \
-s 10.0.0.0/8 -p tcp --dport 443 -j ACCEPT
firewall-cmd --list-services
firewall-cmd --list-ports
firewall-cmd --permanent --add-masquerade
Package Management (DNF / RPM)
dnf install httpd
dnf remove httpd
dnf update
dnf update httpd
dnf autoremove
dnf search nginx
dnf info httpd
dnf whatprovides /usr/bin/vim
dnf list installed
dnf list available | grep httpd
dnf history list
dnf history info <id>
dnf history undo <id>
rpm -qa
rpm -qi httpd
rpm -ql httpd
rpm -qf /usr/sbin/httpd
rpm -ivh package.rpm
rpm -V httpd
subscription-manager register --username=user --password=pass
subscription-manager attach --auto
subscription-manager repos --list-enabled
subscription-manager repos --enable=rhel-9-for-x86_64-appstream-rpms
Performance Analysis
top / htop
mpstat -P ALL 1 5
sar -u 1 10
perf top
perf record -ag sleep 10
perf report
free -h
vmstat -s
cat /proc/meminfo
sar -B 1 10
slabtop
iostat -xhz 2
iotop -d 2
lsblk -io NAME,SIZE,ROTA,SCHED,TYPE
sar -n DEV 1 10
nethogs -d 2
ss -s
nstat -z
sar -A
dstat
systemd-analyze blame
tuned Profiles
tuned-adm list
tuned-adm active
tuned-adm profile throughput-performance
tuned-adm profile latency-performance
tuned-adm profile virtual-guest
tuned-adm profile balanced
kdump / Crash Analysis
systemctl enable --now kdump
grubby --info=ALL | grep args
echo 1 > /proc/sysrq-trigger
echo c > /proc/sysrq-trigger
ls /var/crash/
crash /usr/lib/debug/lib/modules/$(uname -r)/vmlinux /var/crash/<timestamp>/vmcore
crash> bt
crash> log
crash> ps
crash> vm
crash> files
Security Hardening
authselect list
authselect select sssd with-faillock
systemctl enable --now auditd
auditctl -l
auditctl -w /etc/passwd -p wa -k passwd-changes
ausearch -k passwd-changes
aureport --summary
vi /etc/sshd/sshd_config
PermitRootLogin no
PasswordAuthentication no
MaxAuthTries 3
AllowUsers ryan
Protocol 2
systemctl restart sshd
fips-mode-setup --enable
update-crypto-policies --set FIPS
Key RHEL Log Locations
| Log / Source | View with |
|---|
| systemd journal | journalctl -xe |
/var/log/messages | Traditional syslog (RHEL 7); less used in 8/9 |
/var/log/secure | SSH, sudo, PAM auth events |
/var/log/dnf.log | Package install/remove history |
/var/log/audit/audit.log | SELinux and auditd |
/var/log/boot.log | Boot messages |
dmesg + /var/log/dmesg | Kernel ring buffer |
/var/crash/ | kdump vmcore files |
LINUX_RHEL_KNOWLEDGE
Append discoveries here. Format: YYYY-MM-DD: <note>