Notes New
Notes New
GRUB 2 displays a boot menu during startup. You can use this menu to select the
kernel version or operating system to boot.
GRUB_DEFAULT=0: Sets the default menu entry. 0 indicates the first entry.
GRUB_TIMEOUT=5: Sets how long the menu will wait (in seconds) before automatically
booting the default entry.
GRUB Command Line: If GRUB fails, you might be dropped into the GRUB command line.
From here, you can manually specify the kernel and
boot parameters to start the OS.
Rescue Mode: On Oracle Linux, boot into rescue mode from the installation media to
reinstall or repair GRUB if it becomes corrupted.
To re-scan for additional OS installations (if added after Oracle Linux), ensure
os-prober is installed, then run:
Kernel parameters can be modified temporarily during boot from the GRUB menu or
permanently by editing GRUB_CMDLINE_LINUX in /etc/default/grub.
Common parameters include quiet (for minimal boot messages) and rhgb (for Red Hat
graphical boot).
Example of /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
If GRUB 2 does not automatically detect the other OS, you can manually add an entry
by editing the /etc/grub.d/40_custom file.
sudo mdadm --manage /dev/md0 --fail /dev/sdb --remove /dev/sdb --add /dev/sdb
sudo mdadm --manage /dev/md0: This part specifies that the mdadm command will
manage the RAID array device /dev/md0.
--fail /dev/sdb: Marks /dev/sdb as "failed" within the RAID array. This tells the
RAID array to stop using /dev/sdb as an active disk.
RAID will begin using other disks to manage redundancy and data integrity if it's
configured to do so.
--remove /dev/sdb: Removes /dev/sdb from the RAID array. After marking the disk as
failed, this step fully detaches /dev/sdb from the array configuration,
making it eligible to be replaced or added back in.
--add /dev/sdb: Re-adds /dev/sdb back to the RAID array as a fresh, active disk.
Once re-added, RAID will begin syncing and rebuilding data onto
/dev/sdb as part of the array, as if it were a new or repaired disk.
This sequence is typically used when you want to force a resync of a disk within a
RAID array. This might be helpful if you suspect data corruption
or want to reinitialize the disk's data without physically replacing the disk.
nmcli connection add type vlan ifname vlan100 dev eth0 id 100
nmcli connection modify vlan100 ipv4.addresses 192.168.100.10/24
nmcli connection modify vlan100 ipv4.gateway 192.168.100.1
nmcli connection modify vlan100 ipv4.dns "8.8.8.8 8.8.4.4"
nmcli connection modify vlan100 ipv4.method manual
nmcli connection modify vlan100 vlan.priority 1
nmcli connection modify vlan100 connection.autoconnect yes
nmcli connection modify vlan100 802-3-ethernet.mtu 1500
Then activate it
nmcli connection up vlan100
/etc/auto.nfs:
Manages the /mnt/nfs directory, automatically creating mount points for data, logs,
and backup.
The backup mount point is read-only (ro), while data and logs are read-write (rw).
cgroups are the core mechanism for resource management in the kernel, allowing
direct control of CPU, memory, and I/O usage for processes.
eg: echo "100M" > /sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes
Slices in systemd are logical groupings of units built on top of cgroups, allowing
administrators to enforce resource policies across large sections of the system
without managing individual processes directly.
eg: [Slice]
MemoryMax=1G
CPUQuota=50%
In Linux 8, cgroups v2 is enabled by default, but some systems may still require
cgroups v1
In cgroups v2, resources are managed in a hierarchical structure where each cgroup
can have multiple sub-cgroups, allowing fine-grained resource control.
Controllers in cgroups v2
In Linux 8, systemd is tightly integrated with cgroups, and each systemd unit
(service, scope, or slice) automatically creates its own cgroup.
Resource limits can be set for systemd units using unit files by adding directives
under the [Service] or [Slice] sections, such as CPUQuota, MemoryMax, and IOWeight.
Example of a unit file configuration:
[Service]
CPUQuota=50%
MemoryMax=1G
These settings can be dynamically modified using the systemctl command with set-
property:
You can check resource usage and limits within the cgroup filesystem. For
example:
cat /sys/fs/cgroup/memory.max
cat /sys/fs/cgroup/cpu.max
To limit a process to 512MB of memory and 25% CPU usage in a cgroup using systemd:
[Service]
ExecStart=/path/to/your/application
MemoryMax=512M
CPUQuota=25%
This configuration will create a systemd-managed cgroup with specified memory and
CPU limits, providing controlled resource allocation for myapp.
dmesg options:
Option Description
-C, --clear Clears the kernel ring buffer without displaying any messages.
-c Prints the kernel ring buffer contents and then clears it.
-T, --ctime Shows timestamps in a human-readable date and time format.
-H, --human Displays output in a human-readable format with interactive scrolling.
-k, --kernel Shows only kernel-related messages, hiding user-space messages.
-l, --level Filters messages by log level (e.g., err, warn, info).
-n, --console-level Sets log level for messages displayed on the console.
-r, --raw Shows raw format without additional formatting.
-f, --facility Filters messages by facility, such as kern, user, mail.
-s, --buffer-size Limits output to a specified number of bytes (e.g., -s 1000).
-x, --decode Decodes facility and priority for debugging purposes.
-w, --follow Continuously monitors new messages in real-time (like tail -f).
Anacron only runs daily, weekly, and monthly jobs, and it will run missed jobs
upon the next system startup.
Cron can run at any frequency (including minutely and hourly), so if both cron
and anacron are configured for the same task, cron might run the job multiple times
a day, while anacron would run it only once if missed.
NTP (via Chrony) is the default method for time synchronization in Oracle Linux
8, and it is easy to configure for general-purpose time synchronization.
PTP is used for higher-precision synchronization and is implemented through the
linuxptp package, supporting nanosecond-level accuracy.
Both services can run simultaneously on a system, allowing for general time
synchronization (NTP) alongside highly accurate synchronization (PTP) as needed.
Protocol: NTP uses a client-server model where clients request time from NTP
servers. PTP uses a master-slave model where one clock (master) distributes time to
other clocks (slaves) in the network.
QN:17 - C
QN:26 - A,C
precedence for SSH client configuration is:
. Password Lifetime
Definition: Password lifetime specifies the maximum duration (in days) that a
password can be used before it must be changed.
Purpose: It enforces regular password changes, enhancing security by limiting
how long a password can remain the same.
Configuration: This is controlled by setting the maximum password age in
/etc/login.defs or by using the chage command.
Example: If PASS_MAX_DAYS is set to 90, users must change their password every
90 days.
2. Password Expiry
Definition: Password expiry sets a specific date when a password will expire,
regardless of when it was last changed.
Purpose: It enforces a hard expiration date for passwords, which may be useful
in scenarios where access needs to end on a specific date (e.g., temporary
accounts).
Configuration: This can be set per user using the chage command with the -E
option to specify an expiration date.
Example: Running chage -E 2024-12-31 username sets the user’s password to
expire on December 31, 2
/etc/login.defs
userlist_enable=YES: This setting enables the use of the user list file,
typically located at /etc/vsftpd.user_list.
Whether users in this list are allowed or denied access depends on another
setting, userlist_deny.
userlist_deny=YES (default): If userlist_deny is set to YES, users listed in
vsftpd.user_list are denied FTP access.
userlist_deny=NO: If userlist_deny is set to NO, only users listed in
vsftpd.user_list are allowed FTP access.
To summarize:
Controls various aspects of the FTP server, including security, user access,
permissions, logging, and passive/active FTP modes.
/etc/vsftpd/user_list:
A list of usernames that can either be allowed or denied access to the FTP
server based on userlist_deny setting in vsftpd.conf.
If userlist_deny=YES, users in this list are denied access. If
userlist_deny=NO, only users in this list are allowed access.
/etc/vsftpd/ftpusers:
A file that specifies a list of users who are always denied FTP access,
regardless of other settings.
Typically, system users like root, bin, daemon, etc., are listed here to
prevent them from FTP login for security reasons.
/etc/pam.d/vsftpd
This file configures the Pluggable Authentication Modules (PAM) for VSFTPD.
Controls how authentication is handled for users trying to log in via FTP.
This file allows VSFTPD to integrate with the system’s authentication
mechanisms, including password checks and user restrictions.
Log Files: /var/log/vsftpd.log
Skopeo allows inspecting images directly from registries without needing to pull
them, providing metadata and other image details.
podman inspect
Purpose: Primarily used to inspect images and containers that are stored
locally or actively running on the host machine.
Command Syntax:
Use Case: When you want to retrieve metadata or configuration details about a
container or image stored on your local system, such as environment variables,
ports, labels, mount points, and network settings.
Output Details:
skopeo inspect
Scope: Remote and Local Images
Command Syntax:
Use Case: When you want to view metadata about an image stored in a remote registry
(such as Docker Hub or a private registry) without downloading it.
This is useful for quickly checking image details (like layers and size) directly
from the source registry.
Output Details:
Provides image metadata such as size, digest, creation date, and supported
architectures.
It does not include extensive local container configuration details because
it’s intended for retrieving basic image information across multiple locations.
sudo usermod -aG project_team alice adds alice to the project_team group in
addition to her private group
umask: In the UPG model, the default umask value is typically set to 002 for user-
created files. This setting determines the default permissions for new files and
directories:
Files are created with 664 permissions (rw-rw-r--), making them readable and
writable by the user and their private group, but read-only for others.
Directories are created with 775 permissions (rwxrwxr-x), allowing full access for
the user and their group but read-only for others.
This model avoids excessive restriction while maintaining control, as only users
within the same group have write access to shared files.
Command Description
auditctl -l List current audit rules
auditctl -a always,exit -F arch=b64 -S execve Log every execve system call on a
64-bit system
auditctl -w /etc/passwd -p rwxa Monitor access (read, write, execute, and
attribute change) to /etc/passwd
auditctl -d Delete a specific rule
sudo ausearch -m execve Search audit logs for execve system calls
-a always,exit: This specifies that the rule should apply to all processes (whether
successful or not) for a specific system call or action.
-F arch=b64: This option is used to specify the architecture. For a 64-bit system,
arch=b64 should be used.
-S <syscall>: The system call (e.g., execve, open, read, write) to be audited.
-w <path>: Watch a specific file or directory.
-p <permissions>: Define the permissions to monitor on the file (e.g., r for read,
w for write, x for execute, a for attribute changes).
To monitor file open events for all files, you can use the following rule:
By default, the rules set with auditctl are not persistent across reboots. To make
them persistent, you need to add them to the
/etc/audit/rules.d/ directory in a rules file.
To create persistent rules, you can either directly edit the file
/etc/audit/rules.d/audit.rules, or you can create a custom rules file:
Audit logs are typically stored in /var/log/audit/audit.log. You can view the logs
with ausearch, which is a utility to query and search through the audit logs.
systemd is the core system and service manager, handling the startup, management,
and shutdown of system services. It replaces the older init system and introduces a
unified way to manage services, processes, and other system components.
The Service Manager is a systemd component that manages these services, making it
easy to start, stop, restart, enable, and disable services.
sudo nmcli connection add type bond ifname bond0 mode active-backup
sudo nmcli connection add type bond-slave ifname eth0 master bond0
sudo nmcli connection add type bond-slave ifname eth1 master bond0
sudo nmcli connection modify bond0 ipv4.addresses 192.168.1.100/24
sudo nmcli connection modify bond0 ipv4.method manual
sudo nmcli connection up bond0
/etc/lvm/lvm.conf
In Oracle Enterprise Linux 8, systemd is the system and service manager responsible
for controlling services, processes, and system states.
Units: systemd organizes everything as units
(e.g., .service, .socket, .target, .timer, and .mount).
Service Units: Manage services or daemons (e.g., httpd.service for Apache).
Target Units: Represent system states or goals (e.g., multi-user.target,
graphical.target).
SYNOPSIS
firewalld [OPTIONS...]
DESCRIPTION
firewalld provides a dynamically managed firewall with support for
network/firewall zones to define the trust level of network connections or
interfaces. It
has support for IPv4, IPv6 firewall settings and for ethernet bridges and
has a separation of runtime and permanent configuration options. It also supports
an interface for services or applications to add firewall rules directly.
In nftables, rules are organized into tables, and tables contain chains. Each chain
holds a set of rules that determine the actions on network packets
at various stages of the packet processing pipeline. The persistent configuration
is typically saved in /etc/sysconfig/nftables.conf.
There are three types of chains:
Input Chain (input): Handles incoming packets destined for the local system.
Output Chain (output): Handles outgoing packets originating from the local system.
Forward Chain (forward): Handles packets that are being forwarded between different
network interfaces (e.g., a router).
Each chain can have rules that determine what actions should be taken on packets
(e.g., accept, drop, log, etc.).
/proc files system and the properties of files within the /proc file system
difference between cgroup1 and 2
chroot jail
disable selinux temporarily
ls /sys/fs/cgroup/
If you see subdirectories like cpu, memory, blkio, and others, it's using cgroup
v1.
If you see a directory called unified, it's using cgroup v2.
Feature cgroup v1
cgroup v2
Hierarchy Multiple hierarchies for different controllers
Single unified hierarchy for all controllers
Controller Management Independent controllers in separate hierarchies
Unified set of controllers for all resources
Resource Control Less advanced, fragmented support More
advanced, unified resource control
Delegation Not supported
Supports delegation and granular control
Process Management Per-hierarchy assignment of tasks
Single hierarchy for all process management
Security and Permissions Fragmented, different models per controller
Unified permission model for all controllers
Compatibility Widely used in older systems and applications
Not backward compatible with cgroup v1
Default in OEL 8 Supported but not the default
Default for most services (systemd, containers)
Virtual and Dynamic: Files in /proc do not exist on the disk; they are created in
memory by the kernel at runtime.
Kernel Interface: Provides access to kernel-related parameters, system statistics,
and process information.
Process-Specific Information: Directories and files in /proc contain information
about running processes, resource usage, and kernel settings.
System Monitoring: It's a valuable tool for system administrators and developers
for real-time system monitoring, debugging, and performance tuning
Text-based: Most files in /proc are text files, making it easy for administrators
and scripts to read and extract information.
Dynamic: The contents of the files are updated in real-time as the system changes.
For example, if the system's memory usage changes, the contents
of /proc/meminfo will automatically reflect those changes.
Read/Write: Some files in /proc are readable only, while others are writable,
allowing you to change kernel parameters. For instance, you can change
settings in /proc/sys/ by writing to certain files, which affect kernel behavior
immediately without requiring a reboot.
Each running process has its own directory named after its Process ID (PID). Inside
this directory, you can find various files that contain information about the
process.
For example:
/proc/1234/ – The directory for the process with PID 1234.
Files within each process directory:
/proc/[pid]/status: Information about the process, including memory usage, process
state, etc.
/proc/[pid]/cmdline: The command line that started the process.
/proc/[pid]/fd/: A directory that contains symbolic links to the file descriptors
opened by the process.
/proc/[pid]/stat: Detailed information about the process, including state, memory
usage, CPU usage, etc.
/proc/[pid]/mem: This represents the memory of the process.
cat /proc/cpuinfo
Outputs details such as the number of CPUs, model name, cache size, and other CPU
features.
cat /proc/meminfo
Displays information such as total memory, free memory, buffers, swap usage, etc.
/proc/uptime - System Uptime:
Contains two values: the system's total uptime (in seconds) and the amount of time
the system has been idle.
Example:
cat /proc/uptime
Displays information about the Linux kernel version and the GCC version used to
compile it.
Example:
cat /proc/version
Output might look like: Linux version 4.18.0-240.el8.x86_64 (gcc version 8.3.1
20190507 (Red Hat 8.3.1-5)) #1 SMP Thu Dec 12 12:30:01 EST 2019
Lists all file systems supported by the kernel, including mounted and available
file systems.
Example:
cat /proc/filesystems
/proc/mounts - Mounted Filesystems:
cat /proc/mounts
Output will include details like device, mount point, file system type, and mount
options.
Contains files that control kernel parameters. These can be modified to configure
various kernel settings in real-time (e.g., network settings, security settings,
and more).
For example, to change the maximum number of open files:
bash
Copy code
echo 1024 > /proc/sys/fs/file-max
Examples:
/proc/sys/net/ipv4/ip_forward: Controls IP forwarding.
/proc/sys/vm/swappiness: Controls the kernel's preference for swapping.
/proc/partitions - Disk Partition Information:
Displays the system's load average over the last 1, 5, and 15 minutes.
Example:
bash
Copy code
cat /proc/loadavg
Output example:
Copy code
0.01 0.05 0.08 1/1949 12456
/proc/self - Self Information:
augenrules
augenrules is a utility that helps to load and manage audit rules. Specifically, it
scans files in the /etc/audit/rules.d/ directory for individual rule files and then
combines these rules into a single, optimized rule set for the Audit Daemon. It is
commonly used to build persistent rules that survive reboots.
Load Rules: To generate and load rules from the files in /etc/audit/rules.d/:
augenrules --load
This command reads the rule files, compiles them, and loads the resulting rules
into the active audit system.
Check Rules: To check for any syntax errors in the rule files before applying:
augenrules --check
This will identify errors in rule definitions that could prevent them from being
loaded.
/etc/audit/rules.d/example.rules)
Here is a simple example rule file to audit login events and modifications to
/etc/passwd:
After creating this file, you can load it using augenrules --load
auditctl: Primarily used for adding, removing, or modifying audit rules in real-
time. Rules set with auditctl do not persist across reboots.
augenrules: Used for setting persistent audit rules that apply every time the Audit
Daemon starts. It reads and consolidates rule files from /etc/audit/rules.d/ to
make configuration management easier.
cfroup_no_v1
Explanation:
-a: Adds the new file context.
-t httpd_sys_content_t: Assigns the httpd_sys_content_t context (which is used for
web content files).
"/new/location(/.*)?": Specifies the path (with a wildcard to include
subdirectories).
Restart Nginx and check for any SELinux denials, applying additional SELinux rules
if needed.
sudo systemctl restart nginx
sudo ausearch -m avc -ts recent
This ensures that SELinux allows Nginx to read and serve content from the new
location while maintaining security policies.
nglix remove
root_squash
setfacl -m m::rw
m::rw: Specifies the mask (permissions limit) to rw (read and write) for all ACL
entries. The mask limits the permissions that other ACL entries can have.
In ACL, the mask (m) defines the maximum permissions for users (other than the
owner) and groups. Setting it to rw means that no user or group can have more than
read and write permissions on OEL8.
The main configuration file for chronyd is /etc/chrony.conf, where you can specify
NTP servers, configure time sources, define access rules, and more.
anonymous_enable: Enables or disables anonymous FTP access (YES or NO). - FTP write
access
This command pulls the ubuntu image from Docker Hub (the default registry) with the
latest tag.
The -F option in auditctl is a filtering option for creating detailed audit rules
based on specific conditions.
It does not specify when to start auditing but rather defines criteria that must be
met for the rule to trigger.
Here's a breakdown of some common filters that can be used with auditctl -F:
This rule captures all open system calls by the user with UID 1000.
This captures all open system calls made by users in the group with GID 1001.
The key option can be used with -F to label events, making them easier to
search for later:
This tags any access to /etc/shadow with shadow_access for easy searching in
audit logs.
This captures all execve calls made by the process with PID 1234.
Filter by Capability
This rule captures capset calls made by users with an AUID (Audit User ID) greater
than or equal to 1000.
ksplice can update which user patches -> openssh, openssl, glib, kernal ....
ss command
rsyslog - include/exclude
To view and manage LVM volumes in detail, users need root or sudo privileges. With
elevated permissions, users can use the following commands:
partition tables
wireshark/tshark - On Oracle Enterprise Linux 8 (OEL8), you can install and use
Wireshark and TShark (the command-line version of Wireshark) to
capture and analyze network packets.
XFSGROWFS
auditctl load/list/control/
--all-tags, -a
Pulls all tags of an image instead of just the specified tag.
Example: podman pull -a docker.io/library/ubuntu
--authfile
Specifies the path to the authentication file for logging into a private
registry.
Example: podman pull --authfile /path/to/auth.json docker.io/library/ubuntu
--cert-dir
Sets the directory where certificate files are stored for accessing a
registry securely (e.g., .crt, .cert, .key).
Example: podman pull --cert-dir /path/to/certs docker.io/library/ubuntu
--creds
Allows you to specify username and password for authenticating to a
registry. The format is username:password.
Example: podman pull --creds myuser:mypassword registry.example.com/myimage
--quiet, -q
Reduces the output, showing minimal details during the pull operation.
Example: podman pull -q docker.io/library/ubuntu
--tls-verify
Toggles TLS verification for the registry. Use --tls-verify=false to pull
from a registry without verifying its certificate (useful for self-signed
certificates).
Example: podman pull --tls-verify=false registry.example.com/myimage
--no-store
Disables saving the image in local storage. This option is typically used
in specific use cases, like one-off analysis.
Example: podman pull --no-store docker.io/library/ubuntu
--override-arch
Forces podman to pull an image for a specified architecture, such as arm64
or amd64.
Example: podman pull --override-arch=arm64 docker.io/library/ubuntu
--override-os
Similar to --override-arch, this option forces pulling an image for a
specified operating system, like linux or windows.
Example: podman pull --override-os=linux docker.io/library/ubuntu
--override-variant
Specifies the variant of the architecture, useful in cases where an
architecture has multiple variants (e.g., ARM's v7 or v8).
Example: podman pull --override-variant=v7 docker.io/library/ubuntu
GRUB_CMDLINE_LINUX="cgroup_no_v1=all"
This disables cgroups v1 entirely, making the system use only cgroups v2.
cgroup_no_v1=memory,blkio
This disables the memory and blkio (block I/O) controllers for cgroups v1, while
leaving other controllers in v1 mode if needed.
The cgroup_no_v1 parameter allows you to disable specific or all controllers from
using cgroups v1 in favor of using the unified cgroups v2 hierarchy.
The cgroup_no_v1 parameter allows you to disable specific or all controllers from
using cgroups v1 in favor of using the unified cgroups v2 hierarchy.
Binary Log Storage: Logs are stored in binary format, which enables quick querying
and reduced disk usage. Unlike traditional text logs in /var/log,
this format allows structured and organized data retrieval.
Centralized Logging: systemd-journald aggregates logs from different sources,
including the kernel, boot messages, and individual service logs,
into a single system.
Log Persistence: Logs are stored either temporarily in /run/log/journal/ (volatile
storage cleared on reboot) or persistently in /var/log/journal/
(if configured for permanent storage).
Data Integrity: Journald verifies log integrity to help detect tampering or
corruption.
The configuration file for systemd-journald on Oracle Enterprise Linux 8 (OEL8) is:
/etc/systemd/journald.conf
Compress= Enables compression of log files to save space (yes or no). ---Default
yes
Modify the options as needed. For example, to enable persistent logging, set:
Storage=persistent
Save the changes and restart systemd-journald for the changes to take effect:
The iproute2 package in Linux provides a suite of networking tools that replace
many of the older networking utilities.
It is used for advanced network management tasks, such as configuring network
interfaces, managing routes, setting up network namespaces, and more
iproute2 Commands:
Command Description
ip link Manage network interfaces.
ip addr Manage IP addresses.
ip route Manage routes and routing tables.
ip addr add Add an IP address to an interface.
ip link set Enable or disable network interfaces.
ss Display socket statistics and network connections.
tc Configure and manage network traffic control (QoS,
bandwidth shaping).
rtmon Monitor routing table changes.
bridge Manage Ethernet bridges and bridge-related
configurations.
ip netns Manage network namespaces.
sudo ip link add link eth0 name eth0.100 type vlan id 100
Normally, no need for modprobe: The 8021q module is often loaded by default on most
modern Linux distributions, so you should not need to manually load it.
If needed, use modprobe 8021q to load the VLAN kernel module, and you can ensure it
is loaded on boot with the /etc/modules-load.d/ configuration.
cryptsetup is a utility for managing LUKS (Linux Unified Key Setup) and plain dm-
crypt encrypted devices. It is used to set up, configure, and manage encrypted
volumes to secure data.
PARTITIONS:
Specific partitions like /dev/sda1.
LVM DEVICES:
Logical Volumes (LVs) created within LVM.
Volume Groups (VGs) indirectly, by encrypting the PV or LV.
RAID DEVICES:
Devices managed by RAID (e.g., /dev/md0) can be encrypted like any block
device.
SWAP DEVICES:
Swap partitions or files (use cryptsetup with --TYPE=PLAIN for ephemeral
swap encryption).
Configuration Files
/etc/crypttab:
Used to automatically open encrypted volumes during boot. Example:
/etc/fstab:
dm-crypt is the kernel-level device mapper encryption module used to encrypt block
devices on Linux. It provides encryption functionality to tools like cryptsetup,
enabling you to secure physical disks, logical volumes, RAID arrays, and swap
devices.
Options:
--type luks1: Use LUKS1 format (default on OEL8 is LUKS2).
--cipher aes-xts-plain64: Specify the encryption cipher.
--key-size 256: Set encryption key size.
--hash sha256: Define the hash function for key derivation.
Open (Unlock) the Encrypted Device: Create a mapped device for the encrypted block
device:
Create a File System: Format the mapped device with a file system:
The error swapon: /.swapfile: read swap header failed indicates that the swap file
is not properly initialized as swap space.
Create the swap file (replace <size> with the desired size, e.g., 1G):
cat /proc/swaps
Sample Output:
Sample Output:
SwapTotal: 2097148 kB
SwapFree: 2097148 kB
SwapCached: 0 kB
root_squash: When enabled, this option maps the root user (UID 0) on the client
machine to a non-privileged user (typically nobody) on the NFS server. This
prevents the client’s root user from having root privileges on the server,
enhancing security.
no_root_squash: This option disables the mapping of the root user to nobody. This
allows the root user on the client machine to have root privileges on the NFS
server as well, which may be required in some specific use cases but introduces
potential security risks.
With root_squash:
The root user on the client machine (UID 0) is mapped to a non-privileged user
on the NFS server (usually nfsnobody or nobody, with UID 65534).
This ensures that the root user does not have unrestricted access to the NFS
share, preventing possible unauthorized changes or damage.
With no_root_squash:
The root user on the client machine is allowed to have root privileges on the
NFS server.
This might be necessary in certain configurations but is generally considered
risky because it exposes the server to potential abuse or mistakes by the root user
on the client.
The root_squash and no_root_squash options are configured in the /etc/exports file
on the NFS server.
Using root_squash (default)
/shared_directory <client_ip_or_network>(rw,sync,root_squash)
all_squash: This option maps all clients’ requests (including root) to the
nfsnobody user. It’s typically used for shared data where no client should have
elevated privileges.
Hostname Management:
Modern systems prefer managing hostnames using the hostnamectl command or
by editing /etc/hostname, rather than relying on /etc/sysconfig/network.
Contents of /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=myserver.example.com
GATEWAY=192.168.1.1
Syntax:
NM_CONTROLLED=yes
[main]
plugins=ifcfg-rh
cat /etc/NetworkManager/NetworkManager.conf
[keyfile]
unmanaged-devices=interface-name:eth0
If any interfaces are listed under unmanaged-devices, they are not managed by
NetworkManager.
Example Output:
NetworkManager does not manage all interfaces by default but manages those defined
in its profiles unless explicitly excluded.
To control which interfaces NetworkManager handles, use
/etc/NetworkManager/NetworkManager.conf or the NM_CONTROLLED directive in
traditional ifcfg files.
Managed by Default:
NetworkManager manages interfaces defined in its connection profiles
located in /etc/NetworkManager/system-connections/.
It dynamically manages interfaces unless explicitly instructed not to.
Unmanaged Interfaces:
Interfaces are not managed by NetworkManager if:
They are configured manually using traditional configuration files
(e.g., /etc/sysconfig/network-scripts/).
The unmanaged directive is set in
/etc/NetworkManager/NetworkManager.conf.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Example:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=no
NM_CONTROLLED=no
To ensure that all interfaces are managed by NetworkManager, remove any unmanaged
directives from /etc/NetworkManager/NetworkManager.conf and legacy configuration
files:
Edit /etc/NetworkManager/NetworkManager.conf:
[keyfile]
unmanaged-devices=
Restart NetworkManager:
If the legacy network service is used, disable it and allow NetworkManager to take
over:
Easy Configuration:
Command-line interface (nmcli) and a graphical tool (nmtui) for easy network
management.
Configuration via standard files in /etc/NetworkManager/.
Connectivity Checks:
Network Profiles:
NetworkManager Components
Command-Line Tools:
nmcli: A powerful command-line interface for managing NetworkManager.
nmtui: A text-based user interface for NetworkManager.
System Services:
NetworkManager service: Manages network interfaces.
network service: Legacy service, usually disabled on modern setups.
Configuration Files:
Located in /etc/NetworkManager/system-connections/.
Each file represents a saved network connection.
Global Configuration:
Connection Profiles:
/etc/NetworkManager/system-connections/
Contains one file per saved network connection.
Log Files:
/var/log/messages: General log file for NetworkManager activities.
Use journalctl for detailed logs:
journalctl -u NetworkManager
Activate/Deactivate a Connection:
Delete a Connection:
Start nmtui:
nmtui
nmcli connection add type ethernet ifname eth0 con-name dhcp-connection ipv4.method
auto
Activate It:
Set a Hostname
/usr/lib/systemd/system:
/etc/systemd/system:
Precedence:
/usr/lib/systemd/system
This directory contains the default unit files provided by installed packages. It
is the primary location where unit files are placed by the operating system or
software packages during installation.
Key Features:
Package-Managed:
Unit files in this directory are managed by the package manager (e.g.,
dnf).
Updates or reinstalls of the package can overwrite these files.
Default Unit Files:
These are the unmodified, original configurations provided by software
vendors.
When to Use:
Do not edit files directly in this directory. Changes can be overwritten during
software updates.
Examples:
/usr/lib/systemd/system/sshd.service
/usr/lib/systemd/system/httpd.service
2. /etc/systemd/system
Administrator-Managed:
Files in this directory take precedence over those in
/usr/lib/systemd/system.
Custom Overrides:
If you need to customize a service, create or edit the unit file here.
Overrides specific to a unit can be placed in a .d directory (e.g.,
/etc/systemd/system/ssh.service.d/).
Persistent Changes:
Unit files in this directory are not affected by package updates.
When to Use:
Examples:
/etc/systemd/system/my-custom.service
/etc/systemd/system/sshd.service.d/custom.conf
Precedence Order
When systemd looks for a unit file, it uses the following precedence (highest to
lowest):
/etc/systemd/system/
/run/systemd/system/ (runtime-only overrides; lost on reboot)
/usr/lib/systemd/system/
If a unit file exists in multiple locations, the one with the highest precedence is
used.
sudo vi /etc/systemd/system/<service>.service.d/custom.conf
[Service]
Environment="CUSTOM_VAR=value"
sudo vi /etc/systemd/system/my-custom.service
[Unit]
Description=My Custom Service
After=network.target
[Service]
ExecStart=/path/to/command
Restart=always
[Install]
WantedBy=multi-user.target
systemctl list-unit-files
systemctl list-units