Posts

Linux & Red Hat Cheat Sheet HTML Rendered

Enterprise Operations

Linux & Red Hat

Linux is the foundation of modern servers, cloud platforms, containers, security tooling, and DevOps automation. Red Hat Enterprise Linux adds enterprise lifecycle, support, hardened defaults, predictable package management, and production-ready platform standards.

KernelHardware control
systemdService manager
DNF/RPMPackages
SELinuxAccess control
🐧 → 🧱 → 🔐

Kernel → Services → Security → Automation

Linux Architecture

Kernel & User Space

Linux is built around the kernel. The kernel manages CPU, memory, disks, network devices, processes, system calls, and security boundaries.

Core layers
  • Hardware: CPU, RAM, disks, NICs
  • Kernel: scheduler, memory, drivers
  • System libraries: glibc and runtime libraries
  • System services: systemd, journald, sshd
  • User tools: bash, dnf, vim, curl
KernelUser SpaceShellDrivers

Red Hat Enterprise Linux

Enterprise Platform

RHEL is designed for enterprise workloads. It focuses on stability, security updates, certified ecosystems, lifecycle management, and automation.

Important RHEL areas
  • RPM package format
  • DNF package manager
  • SELinux policy enforcement
  • firewalld zones and services
  • System roles and automation
RHEL 9RHEL 10RPMDNF

Production Operations

Run & Secure Systems

A production Linux engineer must understand services, logs, permissions, ports, firewall rules, storage, backup, monitoring, and change control.

Daily responsibilities
  • Check system health
  • Review logs and failed services
  • Patch packages safely
  • Manage users and access
  • Monitor disk, CPU, memory, and network
MonitoringPatchingLogsSecurity

Linux Architecture Map

LayerPurposeExamples
HardwarePhysical or virtual resourcesCPU, RAM, disks, NICs
KernelControls hardware and system callsScheduler, memory manager
Init systemStarts and manages servicessystemd, systemctl, journald
SecurityControls access and isolationUsers, groups, sudo, SELinux
ApplicationsBusiness or platform workloadsApache, Nginx, Java, Kafka, Elasticsearch

Production Server Flow

🌐Network
🔥firewalld
⚙️Service
🔐SELinux
📁Storage
📊Logs
A request enters through the network, passes firewall policy, reaches a service, is controlled by SELinux and permissions, writes to storage, and produces logs for troubleshooting.

Linux File System Cheat Sheet

/etcSystem configuration files
/var/logLog files such as messages, secure, audit, and application logs
/var/libPersistent state data for services
/usr/binUser command binaries
/usr/sbinSystem administration binaries
/homeUser home directories
/rootRoot user home directory
/tmpTemporary files
/bootKernel and boot loader files

Essential Linux Commands

# system information
hostnamectl
uname -r
cat /etc/redhat-release

# disk and memory
df -h
du -sh /var/log/*
free -h
lsblk

# processes
ps aux | grep java
top
uptime

# logs
journalctl -xe
journalctl -u sshd -n 100
tail -f /var/log/messages

systemd & Service Management

# service status
systemctl status sshd
systemctl status firewalld

# start, stop, restart
systemctl start nginx
systemctl restart nginx
systemctl stop nginx

# boot behavior
systemctl enable nginx
systemctl disable nginx

# failed services
systemctl --failed
journalctl -u nginx -n 200 --no-pager

DNF & RPM Package Management

# package operations
dnf search nginx
dnf install nginx
dnf update
dnf remove nginx

# package information
rpm -qa | grep nginx
rpm -qi nginx
rpm -ql nginx

# repo checks
dnf repolist
dnf clean all
dnf makecache

Users, Groups, Permissions & sudo

# users and groups
id soheil
getent passwd soheil
getent group wheel

# ownership and permissions
ls -l /etc/ssh/sshd_config
chown root:root file
chmod 644 file
chmod 750 script.sh

# sudo
sudo -l
visudo
Permission example: 644 means owner can read/write, group can read, and others can read. It does not give execute permission.

SELinux & firewalld

# SELinux
getenforce
sestatus
ausearch -m AVC -ts recent
sealert -a /var/log/audit/audit.log

# firewalld
firewall-cmd --state
firewall-cmd --get-active-zones
firewall-cmd --list-all
firewall-cmd --add-service=https --permanent
firewall-cmd --reload

Networking Cheat Sheet

# IP and routes
ip addr
ip route
nmcli connection show

# DNS
resolvectl status
nslookup example.com
dig example.com

# ports
ss -tulpn
ss -tnp | grep 9093
nc -vz server.example.com 443
curl -vk https://server.example.com

Storage, LVM & Filesystems

# block devices
lsblk
blkid
df -hT

# LVM overview
pvs
vgs
lvs

# mount points
findmnt
cat /etc/fstab

# disk usage
du -sh /var/* | sort -h

Logging & Troubleshooting Flow

StepCommandPurpose
Healthuptime, free -h, df -hFind CPU, memory, disk pressure
Servicesystemctl status appCheck running or failed state
Logsjournalctl -u appFind service errors
Networkss -tulpn, nc -vzCheck ports and reachability
Securitygetenforce, firewall-cmdCheck SELinux and firewall blocks

Production Linux Best Practices

AreaGood practiceWhy it matters
AccessUse named users and sudo rulesImproves auditability
PatchingPatch in test before productionReduces outage risk
StorageSeparate logs and application dataProtects root filesystem
ServicesEnable only needed servicesReduces attack surface
FirewallOpen only required portsLimits unwanted access
SELinuxKeep enforcing where possibleAdds strong security boundary
MonitoringAlert on disk, memory, CPU, servicesFinds issues early
DocumentationDocument runbooksSpeeds incident handling

Key Takeaways

Linux architectureUnderstand kernel, user space, services, storage, network, and security layers.
RHEL focusRed Hat adds lifecycle, support, security, and stable package management.
systemdUse systemctl and journalctl together when checking services.
SecurityPermissions, sudo, SELinux, and firewalld must be checked together.
Production mindsetUse monitoring, automation, change control, and repeatable configuration.
LinuxRHELsystemdDNFRPMSELinuxfirewalldLVMAnsibleDevOps