RHCSA Commands: Maintenance
Time Synchronization (Chrony/NTP)
| Command | Description | Example |
|---|---|---|
chronyc sources |
Shows available NTP time sources and their binding status. The * (asterisk) indicates the current active source. |
chronyc sources |
chronyc tracking |
Displays clock performance, stratum level, reference ID, system time offset, frequency, and other statistics. | chronyc tracking |
systemctl enable --now chronyd |
Enables the Chrony service and starts it immediately; sets it to autostart at boot. | systemctl enable --now chronyd |
systemctl status chronyd |
Checks the operational status of the Chrony daemon. | systemctl status chronyd |
timedatectl |
Displays the current local time, universal time, RTC time, time zone, and NTP synchronization status. | timedatectl |
timedatectl set-ntp false |
Disables NTP synchronization. Must be done before manually changing the system time. | timedatectl set-ntp false |
timedatectl set-ntp true |
Re-enables NTP synchronization after manual time changes. | timedatectl set-ntp true |
timedatectl set-time |
Manually sets the system date and time. Requires NTP to be disabled first. | timedatectl set-time "2020-01-01" |
timedatectl set-time |
Sets both date and time in a single command. | timedatectl set-time "2019-11-18 23:20:00" |
date |
Displays the current system date and time. | date |
date -s |
Sets the system date and time manually. | date -s "22 Nov 2019 13:00:00" |
man chrony.conf |
Displays the manual page for the Chrony configuration file, listing all available directives and options. | man chrony.conf |
Chrony Configuration Directives (/etc/chrony.conf)
| Directive | Description | Example |
|---|---|---|
driftfile |
Specifies the location of the drift file that records the rate at which the system clock gains or loses time. | driftfile /var/lib/chrony/drift |
logdir |
Sets the directory location to store Chrony log files. | logdir /var/log/chrony |
pool |
Defines a pool of time servers. Chrony binds to the best one and fails over automatically. iburst sends the first 4 requests every 2 seconds for fast initial sync. |
pool 0.rhel.pool.ntp.org iburst |
server |
Defines a single time server by hostname or IP. 127.127.1.0 represents the local system clock. |
server server20s8.example.com iburst |
server 127.127.1.0 |
Configures the local system clock as the time source (least recommended). | server 127.127.1.0 |
peer |
Identifies a time server running at the same stratum level. A peer both provides and receives time. | peer prodntp1.abc.net |
Hostname Resolution (DNS)
| Command | Description | Example |
|---|---|---|
dig |
Verbose DNS lookup utility (domain information groper). Queries the nameserver from resolv.conf or a specified one. |
dig redhat.com |
dig -x |
Performs a reverse DNS lookup (IP to hostname). | dig -x 209.132.183.105 |
host |
Simple, elementary DNS lookup utility. Produces less output than dig by default. |
host redhat.com |
host -v |
Performs a DNS lookup with verbose output, similar to dig. |
host -v redhat.com |
nslookup |
Classic DNS lookup tool. Can specify a custom DNS server at the end of the command. | nslookup redhat.com 8.8.8.8 |
getent hosts |
Fetches hostname entries based on the order defined in nsswitch.conf (checks local files AND DNS). Supports both forward and reverse lookups. |
getent hosts redhat.com |
DNS Resolver Configuration (/etc/resolv.conf)
| Directive | Description | Example |
|---|---|---|
nameserver |
Specifies a DNS server IP address. Maximum of 3 nameservers allowed. Queried in order. | nameserver 192.168.0.1 |
search |
Specifies up to 6 domain names to append to short hostnames. The first must be the local domain. Replaces the older domain directive. |
search example.net example.org |
domain |
Identifies the default domain name to be searched for queries. | domain example.com |
Name Resolution Order (/etc/nsswitch.conf)
| Entry | Description | Example |
|---|---|---|
hosts: |
Defines the sources and order for hostname resolution. Default is files dns (check /etc/hosts first, then DNS). |
hosts: files dns |
hosts: files [notfound=return] dns |
Modified behavior: return immediately if not found in local files, skipping DNS. | hosts: files [notfound=return] dns |
Kernel Information and Logs
| Command | Description | Example |
|---|---|---|
dmesg |
Displays the kernel ring buffer messages with timestamps relative to kernel start. Shows all kernel-related events. | dmesg |
journalctl -k |
Displays kernel messages from the systemd journal with absolute clock timestamps. Equivalent to journalctl --dmesg. |
journalctl -k |
journalctl --dmesg |
Alternative to journalctl -k; shows kernel messages with absolute clock time instead of relative timestamps. |
journalctl --dmesg |
uname -a |
Displays all relevant system parameters including kernel name, hostname, version, release, machine, processor, and OS. | uname -a |
uname -r |
Shows the current running kernel release version. | uname -r |
uname -v |
Shows the kernel version string. | uname -v |
cat /etc/redhat-release |
Displays the RHEL version and update level currently installed. | cat /etc/redhat-release |
hostnamectl status |
Shows the static hostname, icon name, chassis type, machine ID, boot ID, virtualization info, operating system, kernel version, architecture, and hardware details. | hostnamectl status |
ps aux |
Lists all running processes. Kernel threads are identifiable by names enclosed in square brackets [ ]. |
ps aux | head -n 20 |
Hardware Initialization and Udev
| Command | Description | Example |
|---|---|---|
udevadm monitor |
Monitors real-time kernel and udev hardware events. Useful for observing what happens when plugging in new devices (e.g., USB). Press Ctrl-C to stop. | udevadm monitor |
Udev Rules Directories
| Path | Description |
|---|---|
/usr/lib/udev/rules.d/ |
System-provided default udev rules. Should NOT be modified. |
/etc/udev/rules.d/ |
Custom udev rules directory. Place custom rules here (processed after system rules). |
Kernel Module Management
| Command | Description | Example |
|---|---|---|
lsmod |
Lists all currently loaded kernel modules, their size, and which other modules use them. | lsmod |
lsmod | grep <module> |
Filters the loaded modules list to find a specific module. | lsmod | grep vfat |
lsmod | less |
Pages through the full list of loaded kernel modules. | lsmod | less |
lsmod | head |
Shows the first few lines of loaded modules (useful to see the header). | lsmod | head |
modinfo |
Displays detailed information about a specific kernel module, including filename, license, description, aliases, dependencies, and supported parameters. | modinfo e1000 |
modprobe |
Loads a kernel module and automatically loads all of its dependencies. Preferred over insmod. |
modprobe vfat |
modprobe <module> <param>=<value> |
Loads a kernel module with a specific parameter set. | modprobe cdrom debug=1 |
modprobe -r |
Unloads a kernel module and its dependencies (if not in use). Preferred over rmmod. |
modprobe -r vfat |
modprobe -r <dep>; modprobe -r <module> |
Unloads dependent modules first, then the target module. | modprobe -r sr_mod; modprobe -r cdrom |
lspci |
Lists all hardware devices detected on the PCI bus. | lspci |
lspci -k |
Lists PCI devices along with the kernel drivers in use and available kernel modules for each device. | lspci -k |
lspci -k | head |
Shows the first few lines of PCI device and driver information. | lspci -k | head |
rmmod |
(Legacy) Removes a kernel module. Does NOT handle dependencies. Should NOT be used; prefer modprobe -r. |
rmmod <module> |
insmod |
(Legacy) Inserts a kernel module. Does NOT handle dependencies. Should NOT be used; prefer modprobe. |
insmod <module> |
Kernel Module Configuration Directories
| Path | Description |
|---|---|
/etc/modprobe.d/ |
Directory for custom module configuration files (.conf). Used to set persistent module parameters. |
/usr/lib/modprobe.d/ |
System-provided module configuration files. Should NOT be modified. |
/etc/modules-load.d/ |
Directory for files that auto-load modules at boot. Each file lists module names (one per line). |
/usr/lib/modules-load.d/ |
System-provided auto-load module files. Should NOT be modified. |
Persistent Module Parameter Syntax
| Syntax | Description | Example |
|---|---|---|
options <module> <param>=<value> |
Sets a parameter for a module persistently. Place in a .conf file under /etc/modprobe.d/. |
options cdrom debug=1 |
Kernel Upgrading
| Command | Description | Example |
|---|---|---|
dnf upgrade kernel |
Installs a new kernel version while retaining the old kernel. The last 4 kernels are kept in /boot. GRUB 2 automatically picks up new kernels. |
dnf upgrade kernel |
dnf install kernel |
Alternative to dnf upgrade kernel. Also installs a new kernel beside the old one. |
dnf install kernel |
Kernel-Related Paths
| Path | Description |
|---|---|
/boot |
Directory where kernel files are stored. The last 4 installed kernels are retained here. |
/proc |
Pseudo file system providing an interface to the Linux kernel. Contains detailed status information (e.g., /proc/meminfo). |
/proc/meminfo |
Provides detailed information about each memory segment and current memory usage. |
/sys |
Pseudo file system (sysfs) used by the Linux kernel to track hardware-related settings. Written to by systemd-udevd after hardware initialization. |
/lib/modules/ |
Directory containing kernel module files organized by kernel version. |
File System Operations (Referenced in Module Exercises)
| Command | Description | Example |
|---|---|---|
umount |
Unmounts a mounted file system. Used before unloading modules that are in use. | umount /dev/sr0 |
Service Management (Referenced)
| Command | Description | Example |
|---|---|---|
systemctl enable --now chronyd |
Enables the Chrony service for autostart at boot and starts it immediately. | systemctl enable --now chronyd |
systemctl status chronyd |
Checks the current operational status of the Chrony daemon. | systemctl status chronyd |
Reference: Key Configuration Files
| File | Purpose |
|---|---|
/etc/chrony.conf |
Chrony NTP client configuration file. Defines time sources, drift file, and log directory. |
/etc/resolv.conf |
DNS resolver configuration. Defines nameservers and search domains. |
/etc/nsswitch.conf |
Name Service Switch configuration. Controls the order of hostname resolution sources. |
/etc/hosts |
Local static hostname-to-IP mapping table. Checked first (via files in nsswitch.conf). |
/etc/modprobe.d/*.conf |
Persistent kernel module parameter configuration files. |
/etc/modules-load.d/*.conf |
Module auto-load configuration files (one module name per line). |
/etc/udev/rules.d/ |
Custom udev rules for hardware device initialization. |
/var/lib/chrony/drift |
Chrony drift file tracking clock gain/loss rate. |
/var/log/chrony |
Chrony log directory. |