Show Menu
Cheatography

RHEL command list Cheat Sheet (DRAFT) by

Command list for RHEL

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Version, Kernel & Package details

Verify RHEL installed version
cat /etc/r­edh­at-­release
Verify RHEL has the correct version of SLES installed. Log in as root user.
cat /etc/S­uSE­-re­lease
Display the RHEL kernel version
uname-r
Display the RHEL kernel version
uname -mrs
Display the RHEL kernel version
uname -a
List all packages with RPM
rpm --query --all
List all installed RPM packages
rpm -qa
List all installed YUM packages
yum list installed
List all installed DNF packages
dnf list installed
View current firewall settings
firewa­ll-­config

Notes for SSH

Use SSH Public Key based login
~
Disable root user login
add users to a SUDO group
Disable password based login
Authen­tic­ati­onM­ethods publickey Pubkey­Aut­hen­tic­ation yes
Limit users SSH access
AllowUsers first lastname
Disable empty passwords
Permit­Emp­tyP­ass­words no
Firewall SSH TCP port #22
~
Configure idle log out timeout interval
Client­Ali­veI­nterval 300 Client­Ali­veC­ountMax 0
 

RHEL firewalld

View the current status of firewalld
firewa­ll-cmd --state or systemctl status firewalld
View current firewalld settings in window
firewa­ll-­config
View current firewalld settings via CLI
firewa­ll-cmd --list-all
View what services are allowed in the current firewalld zone
firewa­ll-cmd --list­-se­rvices

SSH & Hostna­mectl identi­fic­ation

Identify Port number in OpenSSH server config file
grep Port /etc/s­sh/­ssh­d_c­onfig
Identify Port number in OpenSSH client config file
grep Port /etc/s­sh/­ssh­_config
Identify system wide OpenSSH config file for client
cat /etc/s­sh_­ssh­_config
View all hostna­mectl
hostna­mectl status
Confirm SSH password authen­tic­ation
grep sshd -T | grep Passwo­rdA­uth­ent­ication
Find all failed SSH login attempts
grep "­Failed passwo­rd" /var/l­og/­aut­h.log
Find all failed SSH login attempts
cat /var/l­og/­aut­h.log | grep "­Failed password
List all IP adddresses that attempted login & failed
grep "­Failed passwo­rd" /var/l­og/­aut­h.log | awk ‘{print $11}’ | uniq -c | sort -nr
(1) Finding failed SSH login attempts
grep "­aut­hen­tic­ation failur­e" /var/l­og/­secure
(1) Finding failed SSH login attempts
grep -E -i 'authe­nti­cation failur­e|I­nvalid user' /var/l­og/­secure | grep sshd
(1) Finding failed SSH login attempts
grep -E 'sshd.*­Fa­ile­d|I­nva­lid­|Di­d|f­ailure' /var/l­og/­secure
(1) Finding failed SSH login attempts
grep -E 'sshd.*­Fa­ile­d|I­nva­lid­|Di­d|f­ailure' /var/l­og/­aut­h.log
(2) Finding failed SSH login attempts (awk print statement may need to be changed)
grep "­aut­hen­tic­ation failur­e" /var/l­og/­secure | awk '{ print $13 }' | cut -b7- | sort | uniq -c
Testing SUDO access
sudo -i
Identify sudoers with author­isation
cat /etc/s­udoers
 

Basic SELinux settings

Display current SELinux state mode
getenforce
Check SELlinux SELINUX variable to persist across rebots
cat /etc/s­eli­nux­/config
Identify if NTP is installed
chkconfig --list ntpd
Identify if ntpd is running
ntpq -p
Check NTP sync status
timeda­tectl
Check NTP sync status
timeda­tectl status