centos for linux

Understanding CentOS: A Comprehensive Overview
CentOS (Community Enterprise Operating System) was a widely used open-source operating system built from the source code of Red Hat Enterprise Linux (RHEL). CentOS was known for its stability, reliability, and enterprise-grade features, making it a preferred choice for many server environments.
What is CentOS?
CentOS is a Linux distribution designed to provide a free, community-supported enterprise-class computing platform. Its unique characteristic was that it was compiled from the publicly available source code of Red Hat Enterprise Linux (RHEL). This meant that CentOS was largely compatible with RHEL, inheriting many of RHEL's features and stability, but without the need for RHEL's commercial license fees.
The CentOS Project was maintained by an active community responsible for recompiling the RHEL source code, removing Red Hat's trademarks, and performing necessary modifications and maintenance.
History and Evolution
The CentOS Project began in 2004 with the initial goal of providing a free, binary-compatible alternative to RHEL. Over the years, CentOS gained widespread recognition, particularly in the server space, becoming a primary platform for deploying applications for many businesses and individuals.
However, in late 2020, the CentOS Project announced a shift in focus from CentOS Linux (a downstream rebuild of RHEL) to CentOS Stream (an upstream development branch of RHEL). This change sparked significant discussion within the community and raised concerns among some users.
CentOS Linux: This is the version of CentOS we were familiar with in the past. It was created by the community rebuilding the RHEL source code after RHEL was released. This meant that CentOS Linux versions typically lagged behind their corresponding RHEL versions but offered high compatibility and stability.
CentOS Stream: This is a rolling-release Linux distribution positioned between Fedora and RHEL. CentOS Stream serves as the upstream development branch for RHEL, meaning future versions of RHEL will be based on the code in CentOS Stream. CentOS Stream is more like a continuously updated preview, containing new features and bug fixes that are slated to land in RHEL.
This change signifies that the maintenance and updates for CentOS Linux will cease after its end-of-life, requiring users to migrate to CentOS Stream or other Linux distributions.
Key Features
CentOS inherited many enterprise-grade features from RHEL:
Stability and Reliability: Based on the solid foundation of RHEL, CentOS was known for its stability in production environments.
Security: CentOS provided robust security features, including SELinux (Security-Enhanced Linux), which helped protect the system from threats.
YUM/DNF Package Manager: CentOS used YUM (Yellowdog Updater, Modified) or DNF (Dandified YUM) in newer versions as its default package manager. These tools made installing, updating, and removing software packages simple and efficient.
sudo yum update
orsudo dnf update
: Updates all packages in the system.sudo yum install <package_name>
orsudo dnf install <package_name>
: Installs the specified package.sudo yum remove <package_name>
orsudo dnf remove <package_name>
: Uninstalls the specified package (keeps configuration files).sudo yum purge <package_name>
orsudo dnf purge <package_name>
: Uninstalls the specified package and its configuration files.
Long-Term Support (LTS): Past CentOS Linux versions offered long-term support, which was crucial for enterprise environments. While CentOS Stream is a rolling release, RHEL itself still provides LTS.
Enterprise Software: CentOS provided broad support for enterprise-grade software, including databases, web servers, development tools, and more.
Community Support: CentOS had a large and active community providing support through forums, mailing lists, and wikis.
Different Versions (CentOS Linux)
During the CentOS Linux era, version numbers typically corresponded to the equivalent RHEL version numbers, e.g., CentOS 7 was based on RHEL 7, CentOS 8 was based on RHEL 8. Each major version had a relatively long lifecycle.
CentOS Stream
The introduction of CentOS Stream changed the CentOS release model. It is no longer a downstream rebuild of RHEL but rather an upstream. This means CentOS Stream has a higher update frequency and includes more experimental features. For production environments requiring extreme stability, users might need to re-evaluate their choice.
System-Level Detailed Content
To provide a more in-depth understanding of CentOS (and by extension, RHEL) from a system perspective, let's delve into some core components and concepts, expanding on the previous details.
File System Hierarchy Standard (FHS)
CentOS adheres strictly to the Filesystem Hierarchy Standard (FHS), a fundamental structure for organizing files and directories on Unix-like systems. Mastery of the FHS is paramount for effective system administration and navigation. Beyond the essential directories previously mentioned, it's important to understand their specific roles and contents:
/
: The root directory, the base of the filesystem tree. Only the root user has write permissions here./bin
: Essential user command binaries required for single-user mode (e.g.,bash
,ls
,cat
)./sbin
: Essential system administration binaries, also needed for single-user mode (e.g.,init
,ip
,mount
)./etc
: Configuration files. This directory contains static configuration files specific to the host. Files here are typically text-based and organized into subdirectories for various services and applications (e.g.,/etc/sysconfig
,/etc/ssh
,/etc/httpd
)./home
: User home directories. Contains personal files and configuration settings for regular users. Permissions are typically set so users can only access their own home directories./root
: The home directory for the superuser (root
). Kept separate from/home
for security and system integrity./usr
: Secondary hierarchy for user data. This is where most user-installed applications and their associated files reside. It's designed to be shareable across multiple systems./usr/bin
: Non-essential command binaries for all users./usr/sbin
: Non-essential system administration binaries./usr/lib
and/usr/lib64
: Libraries for programs in/usr/bin
and/usr/sbin
./usr/local
: Tertiary hierarchy for data locally installed. This is the preferred location for installing software compiled from source or not included in the distribution's repositories, to avoid conflicts with system-managed files.
/var
: Variable data files. Content that is expected to grow or change during system operation./var/log
: Log files. Contains system and application log files. Critical for monitoring and debugging./var/spool
: Spool files for various tasks (e.g., print queues, mail queues, cron jobs)./var/lib
: State information for programs. Persistent data that applications modify as they run (e.g., databases, package manager data)./var/tmp
: Temporary files that should be preserved between reboots (unlike/tmp
).
/opt
: Add-on application software packages. Used for installing larger, self-contained software packages from third-party vendors./dev
: Device files. Contains special files representing hardware devices. These are interfaces to device drivers in the kernel./proc
: Process information virtual filesystem. Provides runtime information about the system and processes. Files here are dynamically generated by the kernel./sys
: System information virtual filesystem. Provides an interface to the kernel's view of devices and drivers. Used for configuring kernel parameters and monitoring hardware./tmp
: Temporary files. Can be cleared upon system reboot./boot
: Boot loader files. Contains the kernel image, initramfs, and bootloader configuration files (e.g.,grub2
)./media
: Mount point for removable media./mnt
: Mount point for temporarily mounted filesystems.
Boot Process (Detailed)
The boot process is a complex sequence of events that initializes the system.
BIOS/UEFI: The firmware performs hardware initialization and POST. It then reads the boot order and loads the bootloader from the designated boot device.
Bootloader (GRUB2): GRUB2 is loaded into memory. It reads its configuration (
/boot/grub2/grub.cfg
), which defines the available operating systems and kernel options. The user can select a kernel or enter the GRUB command line. GRUB2 then loads the selected kernel and the initial RAM disk (initramfs) into memory and passes control to the kernel.Kernel: The kernel starts, initializes devices, and loads necessary modules. It then mounts the initial root filesystem provided by initramfs.
initramfs: The initramfs contains a minimal set of binaries and libraries needed to detect hardware, load necessary kernel modules (especially for storage controllers and filesystems), and mount the real root filesystem. A script within initramfs (
/init
) is executed to perform these tasks. Once the real root filesystem is mounted, the initramfs environment is discarded, and the system pivots to the real root.systemd: The kernel starts the
systemd
process (PID 1), which is the parent of all other processes. systemd reads its configuration and starts services and daemons based on target units. It manages dependencies between services and handles logging via journald. The boot process is considered complete when the default target unit is reached.
Networking Configuration (Advanced)
Beyond basic configuration files, understanding networking involves several layers and tools.
NetworkManager: While user-friendly, NetworkManager can be controlled with fine granularity using
nmcli
(command-line interface) ornmtui
(text user interface). It supports various connection types (Ethernet, Wi-Fi, VPNs, bridges, bonds) and profiles.Traditional Network Scripts: Although NetworkManager is preferred, manual configuration using files in
/etc/sysconfig/network-scripts/
is still possible. Changes here require restarting thenetwork
service (systemctl restart network
).Hostname Resolution: The system resolves hostnames using
/etc/hosts
first, then typically queries DNS servers listed in/etc/resolv.conf
. NetworkManager often manages/etc/resolv.conf
.Firewall (firewalld): CentOS/RHEL uses
firewalld
as the default firewall management tool. It is a dynamic firewall daemon that supports network zones and allows for runtime configuration changes without interrupting existing connections. Configuration is managed using thefirewall-cmd
command-line tool.Network Services: Understanding common network services like SSH (OpenSSH server, configured in
/etc/ssh/sshd_config
), HTTP/HTTPS (Apache HTTP Server or Nginx), and DNS (BIND) is crucial for server administration.Network Tools: Essential command-line tools for troubleshooting and monitoring include
ip
(modern replacement forifconfig
androute
),ss
(replacement fornetstat
),ping
,traceroute
,tcpdump
.
Storage Management
Effective storage management is vital for system performance and data integrity.
Partitioning: Disks are divided into partitions. Common partitioning schemes include MBR (Master Boot Record) and GPT (GUID Partition Table). Tools like
fdisk
,parted
, andgdisk
are used for partitioning.Filesystems: A filesystem organizes data on a partition. CentOS/RHEL primarily uses XFS as the default filesystem for the root partition and other data partitions due to its scalability and performance, especially with large files. Other supported filesystems include ext4, VFAT, and NTFS. Filesystems are created using tools like
mkfs.xfs
,mkfs.ext4
, etc.Mounting: Filesystems must be mounted to a directory in the FHS tree to be accessible. The
mount
command is used for temporary mounts, and the/etc/fstab
file is used for configuring filesystems to be mounted automatically at boot.LVM (Logical Volume Management): LVM provides a layer of abstraction over physical storage devices, allowing for flexible storage management.
Physical Volumes (PVs): Raw disks or partitions are initialized as PVs.
Volume Groups (VGs): PVs are combined into VGs, which act as a pool of storage.
Logical Volumes (LVs): LVs are created from VGs and function like partitions. They can be easily resized, snapshotted, and moved. LVM commands include
pvcreate
,vgcreate
,lvcreate
,lvextend
,lvreduce
.
RAID (Redundant Array of Independent Disks): Hardware or software RAID can be used to improve performance and/or provide data redundancy by combining multiple physical disks into a single logical unit. Software RAID is managed using the
mdadm
tool.
System Monitoring and Performance Tuning
Monitoring system resources is essential for identifying bottlenecks and ensuring optimal performance.
CPU Monitoring:
top
/htop
: Real-time process and system resource monitoring.vmstat
: Reports virtual memory statistics, including CPU usage, memory, swap, and I/O.sar
(System Activity Reporter): Collects and reports system activity information over time, useful for historical analysis of CPU, memory, disk, and network usage.
Memory Monitoring:
free
: Displays the amount of free and used physical and swap memory.vmstat
: Provides memory statistics.
Disk I/O Monitoring:
iostat
: Reports CPU utilization and disk I/O statistics.sar
: Can report disk activity.
Network Monitoring:
ss
/netstat
: Display network connections, routing tables, and interface statistics.tcpdump
: Packet analyzer for network traffic inspection.sar
: Can report network statistics.
Performance Tuning: Involves identifying bottlenecks using monitoring tools and adjusting system parameters (e.g., kernel parameters via
sysctl
), optimizing application configurations, and managing resource allocation.
Security (Advanced)
Security is a multi-layered aspect of CentOS/RHEL.
SELinux (Security-Enhanced Linux): As mentioned, SELinux provides Mandatory Access Control. Understanding SELinux contexts, booleans, and troubleshooting denials (
ausearch
,audit2allow
) is critical for securing the system.Users and Groups: Proper user and group management, including strong password policies, limiting root access, and using
sudo
effectively, is fundamental.SSH Security: Securing the SSH service (
sshd
) is vital, including disabling root login, using key-based authentication instead of passwords, and configuring firewall rules.Firewall (firewalld): Properly configuring
firewalld
zones, services, and port forwarding rules is essential for controlling network access.Auditing (auditd): The Linux Audit Daemon (
auditd
) provides a comprehensive way to log system calls and events, crucial for security monitoring and forensic analysis. Configuration is in/etc/audit/auditd.conf
and audit rules in/etc/audit/rules.d/
.Updates and Patching: Regularly applying security updates and patches via
yum
ordnf
is one of the most important security practices.Intrusion Detection Systems (IDS) / Intrusion Prevention Systems (IPS): Tools like fail2ban can be used to protect against brute-force attacks by dynamically blocking IP addresses based on failed login attempts in logs.
Virtualization and Containerization
CentOS/RHEL has strong support for virtualization and container technologies.
KVM (Kernel-based Virtual Machine): KVM is a full virtualization solution for Linux on x86 hardware with virtualization extensions (Intel VT or AMD-V). It allows the system to run multiple isolated virtual machines (VMs). Management tools include
virsh
,virt-manager
, andqemu-kvm
.Containers: CentOS/RHEL supports containerization technologies, allowing applications to be packaged with their dependencies and run in isolated environments.
Podman: A daemonless container engine for developing, managing, and running OCI Containers on your Linux system. It is often seen as an alternative to Docker.
Docker: A popular platform for building, sharing, and running containerized applications. While not the default in newer RHEL/CentOS Stream versions, it can still be installed and used.
Advantages
Free of Cost: CentOS Linux historically provided a free alternative to RHEL, reducing the cost of adopting an enterprise-grade Linux distribution.
Stability and Reliability: Inherited stability from RHEL made it an ideal choice for server environments.
RHEL Compatibility: High compatibility facilitated migration from RHEL or testing RHEL applications on CentOS.
Security: Offered robust security features.
Community Support: An active community provided ample resources and assistance.
Disadvantages
Shift to CentOS Stream: The end of CentOS Linux and the introduction of CentOS Stream posed a challenge for some users, requiring adaptation to a new release model or seeking alternatives.
Software Update Lag (CentOS Linux): In the CentOS Linux era, software updates could have a delay due to the need to rebuild from RHEL source code after RHEL releases.
Lack of Commercial Support: Unlike RHEL, CentOS did not offer official commercial support; users relied primarily on community support.
How to Get Started with CentOS (CentOS Stream)
If you wish to begin using CentOS Stream, you can follow these steps:
Download: Download the ISO image file for CentOS Stream from the official CentOS website.
Create Bootable Media: Use a tool (such as Rufus, Etcher) to write the ISO image to a USB drive or DVD.
Boot from Media: Restart your computer and configure it to boot from the USB drive or DVD.
Installation: Follow the on-screen instructions to perform the installation.
Conclusion
CentOS was historically a significant component of the enterprise Linux landscape, offering a stable and reliable free option for many users. Although the focus of the CentOS Project has shifted, CentOS Stream, as the upstream branch for RHEL, continues to play an important role in the Red Hat ecosystem. For users requiring RHEL compatibility while also wanting to explore new features, CentOS Stream is a viable option. For production environments demanding long-term stable support, users might need to evaluate other RHEL ecosystem distributions or commercial RHEL.
Subscribe to my newsletter
Read articles from Sakura directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
