Introducing the Linux operating system
Linux is a relatively modern operating system created in 1991 by Linus Torvalds, a Finnish computer science student from Helsinki. Originally released as a free and open source platform prohibiting commercial redistribution, Linux eventually adopted the GNU General Public Licensing (GPL) model in 1992. This move played a significant role in its wide adoption by the developer community and commercial enterprises alike. It is important to note that the Free Software Foundation community distinctly refers to Linux operating systems (or distributions) as GNU/Linux to emphasize the importance of GNU for free software.
Initially made for Intel x86 processor-based computer architectures, Linux has since been ported to a wide variety of platforms, becoming one of the most popular operating systems currently in use. The genesis of Linux could be considered the origin of an open source alternative to its mighty predecessor, Unix. This system was a commercial-grade operating system developed at the AT&T Bell Labs research center by Ken Thompson and Dennis Ritchie in 1969.
Exploring Linux distributions
A Linux operating system is typically referred to as a distribution. A Linux distribution, or distro, is the installation bundle (usually an ISO image) of an operating system that has a collection of tools, libraries, and additional software packages installed on top of the Linux kernel. A kernel is the core interface between a computer’s hardware and its processes, controlling the communication between the two and managing the underlying resources as efficiently as possible.
The software collection bundled with the Linux kernel typically consists of a bootloader, shell, package management system, graphical user interface, and various software utilities and applications.
The following diagram is a simplified illustration of a generic Linux distribution architecture:
Figure 1.1 – Simplified view of a generic Linux architecture
There are hundreds of Linux distributions currently available. Among the oldest and arguably most popular ones are Debian, Fedora, openSUSE, Arch Linux, and Slackware, with many other Linux distributions either based upon or derived from them. Some of these distros are divided into commercial and community-supported platforms.
Important note
As writing this second edition, CentOS became a rolling release and is the base from which future Red Hat Enterprise Linux (RHEL) versions are derived. Its place was taken by other free community distributions that use the RHEL binaries. Among those, Rocky Linux is a good example, and we will reference it throughout this book. One other community distribution based on RHEL is AlmaLinux.
One of the key differences among Linux distributions is the package management system they use and the related Linux package format. We’ll get into more detail on this topic in Chapter 3. For now, the focus is on choosing the right Linux distribution based on our needs. But before being able to decide, you should first know a little about some of the most widely used distributions. Therefore, in the next section, we will briefly present to you some Linux distros.
Common Linux distributions
This section summarizes the most popular and common Linux distributions at the time of writing this edition, with emphasis on their package manager type. Most of these distros are free and open source platforms. Their commercial-grade variations, if any, are noted:
- Fedora, CentOS Stream and RHEL: CentOS and its derivatives use Red Hat Package Manager (RPM) as their package manager. CentOS Stream, now a rolling release distribution, is based on the open source Fedora project. It is suited to both servers and workstations. RHEL is a commercial-grade version derived from CentOS Stream, designed to be a stable platform with long-term support. The community distribution that uses RHEL binaries is Rocky Linux.
- Debian: The package manager for Debian and most of its derivatives is Debian Package (DPKG). Debian is releasing at a much slower pace than other Linux distributions, such as Linux Mint or Ubuntu, for example, but it’s relatively more stable.
- Ubuntu: Ubuntu uses Advanced Package Tool (APT) and DKPG as package managers. Ubuntu is one of the most popular Linux distributions, releasing every 6 months, with more stable Long Term Support (LTS) releases every other year.
- Linux Mint: Linux Mint also uses APT as its package manager. Built on top of Ubuntu, Linux Mint is mostly suitable for desktop use, with a lower memory usage than Ubuntu (with the Cinnamon desktop environment, compared to Ubuntu’s GNOME). There’s also a version of Linux Mint built directly on top of Debian, called Linux Mint Debian Edition (LMDE).
- openSUSE: openSUSE uses RPM, Yet another Setup Tool (YaST), and Zypper as package managers. openSUSE has two versions available: one is called Tumbleweed and is a rolling release, a leading-edge Linux distribution; the other is Leap, a regular release version, which uses the same code base as SUSE Linux Enterprise. Both versions are suited to desktop and server environments. SUSE Linux Enterprise Server is a commercial-grade platform. openSUSE was regarded as one of the most user-friendly desktop Linux distributions before the days of Ubuntu.
Important note
In this book, our focus is mainly on the Linux distributions that are widely used in both community and commercial deployments, such as Ubuntu, Fedora/Rocky Linux, and openSUSE. Most of the examples in this book are equally appliable to any Linux distro. We will specify which one we use for given examples or scenarios.
Now that you know a fair amount of information about the most common Linux distros, in the next section we will give you some hints on how to choose a Linux distribution.
Choosing a Linux distribution
There are many aspects involved in selecting a Linux distribution, based on various functional requirements. A comprehensive analysis would be far beyond the scope of this chapter. However, considering a few essential points may help with making the right decision:
- Platform: The choice between a server, a desktop, or an embedded platform is probably one of the top decisions in selecting a Linux distribution. Linux server platforms and embedded systems are usually configured with the core operating system services and essential components required for specific applications (such as networking, HTTP, FTP, SSH, and email), mainly for performance and optimization considerations. On the other hand, Linux desktop workstations are loaded (or pre-loaded) with a relatively large number of software packages, including a graphical user interface for a more user-friendly experience. Some Linux distributions come with server and desktop flavors (such as Ubuntu, Fedora, and openSUSE), but most distros have a minimal operating system, with further configuration needed (such as Rocky Linux, and Debian). Usually, such distributions would be good candidates for Linux server platforms. There are also Linux distributions specifically designed for desktop use, such as elementary OS, Pop!_OS, or Deepin. For embedded systems, we have highly optimized Linux distros, such as Raspbian and OpenWRT, to accommodate small-form factor devices with limited hardware resources.
- Infrastructure: Today we see a vast array of application and server platform deployments spanning from hardware and local (on-premises) data centers to hypervisors, containers, and cloud infrastructures. Weighing a Linux distribution against any of these types of deployments should take into consideration the resources and costs involved. For example, a multi-CPU, large-memory, and generally high-footprint Linux instance may cost more to run in the cloud or a Virtual Private Server (VPS) hosting infrastructure. Lightweight Linux distributions take fewer resources and are easier to scale in environments with containerized workloads and services (for instance, with Kubernetes and Docker). Most Linux distributions now have their cloud images available for all major public cloud providers (for instance, Amazon AWS, Microsoft Azure, and Google Compute Engine). Docker container images for various Linux distributions are available for download on Docker Hub (https://hub.docker.com). Some Docker images are larger (heavier) than others. For example, the Ubuntu Server Docker image outweighs the Alpine Linux Docker image considerably, and this may tip the balance when choosing one distribution over the other. Also, to address the relatively new shift to containerized workflows and services, some Linux distributions offer a streamlined or more optimized version of their operating system to support the underlying application infrastructure. For example, Fedora features the Fedora CoreOS (for containerized workflows) and Fedora IoT (for Internet of Things ecosystems).
- Performance: Arguably, all Linux distributions can be tweaked to high-performance benchmarks in terms of CPU, GPU, memory, and storage. Performance should be considered very closely with the platform and the application of choice. An email backend won’t perform very well on a Raspberry Pi, while a media streaming server would do just fine (with some external storage attached). The configuration effort for tuning the performance should also be taken into consideration. Rocky Linux, Debian, openSUSE, Fedora and Ubuntu all come with server and desktop versions reasonably optimized for their use. The server versions can be easily customized for a particular application or service, by only limiting the software packages to those that are essential for the application. To further boost performance, some would go to the extent of recompiling a lightweight Linux distro (for instance, Gentoo) to benefit from compiler-level optimizations in the kernel for specific subsystems (for instance, the networking stack or user permissions). As with any other criteria, choosing a Linux distribution based on some application or platform performance is a balancing act, and most of the time, common Linux distros will perform exceptionally well.
- Security: When considering security, we have to keep in mind that a system is only as secure as its weakest link. An insecure application or system component would put the entire system at risk. Therefore, the security of a Linux distribution should be scrutinized as it pertains to the related application and platform environment. We can talk about desktop security for a Linux distro serving as a desktop workstation, for example, with the user browsing the internet, downloading media, installing various software packages, and running different applications. The safe handling of all these operations (against malware, viruses, and intrusions) would make for a good indicator of how secure a system can be. There are Linux distros that are highly specialized in application security and isolation and are well suited for desktop use: Qubes OS, Kali Linux, Whonix, Tails, and Parrot Security OS. Some of these distributions have been developed for penetration testing and security research.
On the other hand, we may consider the server security aspect of Linux server distributions. In this case, regular operating system updates with the latest repositories, packages, and components would go a long way to securing the system. Removing unused network-facing services and configuring stricter firewall rules are further steps for reducing the possible attack surface. Most Linux distributions are well equipped with the required tools and services to accommodate this reconfiguration. Opting for a distro with frequent and stable upgrades or release cycles is generally the first prerequisite for a secure platform (for instance, Rocky Linux, RHEL, Ubuntu LTS, or SUSE Enterprise Linux).
- Reliability: Linux distributions with aggressive release cycles and a relatively large amount of new code added in each release are usually less stable. For such distros, it’s essential to choose a stable version. Fedora, for example, has rapid releases, being one of the fastest-progressing Linux platforms. Yet, we should not heed the myths claiming that Fedora or other similar fast-evolving Linux distros, such as openSUSE Tumbleweed, are less reliable. Don’t forget, some of the most reliable Linux distributions out there, RHEL and SUSE Linux Enterprise (SLE), are derived from Fedora and openSUSE, respectively.
There’s no magic formula for deciding on a Linux distribution. In most cases, the choice of platform (be it server, desktop or IoT) combined with your own personal preferences is what determines the Linux distribution to go for. With production-grade environments, most of the previously enumerated criteria become critical, and the available options for our Linux platform of choice would be reduced to a few industry-proven solutions.
Important note
In this book, our focus is mainly on the Linux distributions that are widely used in both community and commercial deployments, such as Ubuntu, Fedora/Rocky Linux, and openSUSE. That said, most of the examples in this book are equally applicable to any Linux distro. We will specify which one we use for given examples or scenarios.
Now that you know a bit about what a Linux distribution is, along with the most commonly used ones and their use cases, in the following two sections we will present the basic and advanced aspects of Linux installation.