The recent years have marked a significant rise in the adoption of Linux as the operating system of choice for both server and desktop computing platforms. From enterprise-grade servers and large-scale cloud infrastructures to individual workstations and small-factor home appliances, Linux has become an ever-present platform for a wide range of applications.
The prevalence of Linux, perhaps now more than ever, brings into the spotlight much-needed administration skills for a growing community of system administrators and developers. In this book, we take a practical approach to Linux administration essentials, with the modern-day system administrator, DevOps, or developer in mind.
In this first chapter, we'll guide you through the Linux installation process, either on physical hardware (bare metal) or using a Virtual Machine (VM). We'll take you further with a few case studies on choosing a Linux distribution based on functional requirements. Along the way, we introduce you to the Linux graphical user interface with some hands-on examples of configuring GNOME and KDE. Finally, we build a Linux workstation suitable for our daily computing needs.
Here are the topics we cover in this chapter:
We will use the following platforms and technologies in this chapter:
Linux is a relatively modern operating system created in 1991 by Linus Torvalds, a Finnish computer science student at the time, 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 or 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 might be considered the open source alternative of its mighty predecessor, Unix. This system was a commercial-grade operating system developed at AT&T Bell Labs research center by Ken Thompson and Dennis Ritchie in 1969.
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 usually 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:
There are hundreds of Linux distributions currently available. Among the most popular 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.
One of the key differences between 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 later chapters. For now, the focus is on choosing the right Linux distribution based on our needs.
There are many aspects involved in choosing 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:
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 of reducing the possible attack surface. Most Linux distributions are well equipped with the required tools and services to accommodate the preceding. Opting for a distro with frequent and stable upgrades or release cycles is generally the first prerequisite for a secure platform (for instance, Centos, RHEL, Ubuntu LTS, or SUSE Enterprise Linux).
There's no magic formula for choosing a Linux distribution. In most cases, the choice of platform (server or desktop) combined with a couple of the data points mentioned previously and some personal preferences would decide a Linux distribution. 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. In the following section, we enumerate some of the most popular Linux distributions.
This section summarizes the most popular and common Linux distributions at the time of this writing, with emphasis on their package manager. Most of these distros are free and open source platforms. Their commercial-grade variations, if any, are noted.
CentOS and its derivatives use RPM as their package manager. CentOS is based on the open source Fedora project. It is suited to both servers and workstations. RHEL is a commercial-grade version of CentOS, designed to be a stable platform with long-term support.
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 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 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 uses RPM, Yet another Setup Tool (YaST), and Zypper as package managers. openSUSE is a bleeding-edge Linux distribution, suited to both desktop and server environments. SUSE Linux Enterprise Server is the 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 two Linux distributions, widely used in both community and commercial deployments, Ubuntu and CentOS.
The following section presents some hands-on use cases, where, depending on specific functional requirements, we choose the right Linux distribution.
The following use cases are inspired by real-world problems, taken mostly from the authors' own experience in the software engineering field. Each of these scenarios presents the challenge of choosing the right Linux distribution for the job.
This case study is based on the following scenario made from the perspective of a software developer:
The requirements suggest a relatively powerful day-to-day development platform, either as a PC/desktop or a laptop computer. The developer relies on local resources to deploy and test the code (for instance, Docker containers and VMs), perhaps frequently in an offline (airplane mode) environment if on the go.
The system would be primarily using the Linux desktop environment and window manager, with frequent context switching between the Integrated Development Environment (IDE) and terminal windows. The required software packages for the IDE, Docker, hypervisor (VirtualBox), and tools should be readily available from open source or commercial vendors, ideally always being up to date and requiring minimal installation and customization effort.
The choice here would be the Ubuntu Desktop Long Term Support (LTS) platform. Ubuntu LTS is relatively stable, runs on virtually any hardware platform, and it's mostly up to date with hardware drivers. Software packages for the required applications and tools are generally available and stable, with frequent updates. Ubuntu LTS is an enterprise-grade, cost-effective, and secure operating system suitable for organizations and home users alike.
This case study is based on the following scenario made from the perspective of a DevOps engineer:
When it comes to open source, secure, and enterprise-grade web servers, the top choices are usually NGINX, Apache HTTP Server, Node.js, Apache Tomcat, and Lighttpd. Without going into the details of choosing one web server over another, let's just assume we pick Apache HTTP Server. It has state-of-the-art SSL/TLS support, excellent performance, and is relatively easy to configure.
We deploy this web server in VPS environments, in local (on-premises) data centers, or the public cloud. The deployment form factor is either a VM or a Docker container. We are looking for a relatively low-footprint, enterprise-grade Linux platform.
Our choice is CentOS. Most of the time, CentOS and Apache HTTP Server are a perfect match. CentOS is relatively lightweight, coming only with barebone server components and an operating system networking stack. It is widely available as a VPS deployment template in private and public cloud vendors. There is also CentOS Atomic Host, a Linux distribution designed to run Docker containers. Our Apache HTTP Server can run as a Docker container on top of CentOS Atomic, as we may horizontally scale to multiple web server instances.
This case study is based on the following scenario made from the perspective of a software engineer and blogger:
We are looking for a self-managed publicly hosted VPS solution. The related hosting cost is a sensitive matter. Also, the maintenance of the required software packages should be relatively easy. We foresee frequent updates, including the Linux platform itself.
Our pick is Ubuntu Server LTS. As previously highlighted, Ubuntu is a robust, secure, and enterprise-class Linux distribution. The platform maintenance and administration efforts are not demanding. The required software packages – Node.js, Ghost, and MySQL – are easily available and are well maintained. Ubuntu Server has a relatively small footprint. We can run our required software stack for blogging well within the Ubuntu system requirements so that the hosting costs would be reasonable.
This case study is based on the following scenario made from the perspective of a home theater aficionado:
The critical system requirements of a media server are speed (for a high-quality and smooth streaming experience), security, and stability. The related software packages and streaming codecs are subject to frequent updates, so platform maintenance tasks and upgrades are quite frequent. The platform is hosted locally, on a PC desktop system, with plenty of memory and computing power in general. The media is being streamed from the NAS, over the in-house Local Area Network (LAN), where the content is available via a Network File System (NFS) share.
Both Debian and Ubuntu would be excellent choices for a good media server platform. Debian's stable release is regarded as rock solid and very reliable by the Linux community, although it's somewhat outdated. Both feature advanced networking and security, but what may come as a decisive factor in choosing between the two is that Plex Media Server has an ARM-compatible package for Debian. The media server package for Ubuntu is only available for Intel/AMD platforms. If we owned a small-factor, ARM processor-based appliance, Debian would be our choice. Otherwise, Ubuntu LTS would serve our purpose just as well.
This section serves as a quick guide for the basic installation of an arbitrary Linux distribution. For hands-on examples and specific guidelines, we use Ubuntu and CentOS. We also take a brief look at different environments hosting a Linux installation. There is an emerging trend of hybrid cloud infrastructures, with a mix of on-premises data center and public cloud deployments, where a Linux host can either be a bare-metal system, a hypervisor, a VM, or a Docker container.
In most of these cases, the same principles apply when performing a Linux installation. For Docker containerized Linux deployments, we reserve a separate chapter.
Here are the essential steps usually required for a Linux installation.
We start by downloading our Linux distribution of choice. Most distributions are typically available in ISO format on the distribution's website. For example, we can download Ubuntu Desktop at https://ubuntu.com/download/desktop, or CentOS at https://www.centos.org/download/.
Using the ISO image, we can create the bootable media required for the Linux installation. We can also use the ISO image to install Linux in a VM (see the Linux in a VM section).
If we install Linux on a PC desktop or workstation (bare-metal) system, the bootable Linux media is generally a CD/DVD or a USB device. With a DVD writeable optical drive at hand, we can simply burn a DVD with our Linux distribution ISO. But, as modern-day computers, especially laptops, rarely come equipped with a CD or a DVD unit of any kind, the more common choice for a bootable media is a USB drive.
There's also a third possibility of using a so-called PXE boot server. PXE (pronounced pixie) stands for Preboot eXecution Environment, which is a client-server environment where a PXE-enabled client (PC/BIOS) loads and boots a software package over a local or wide area network from a PXE-enabled server. PXE eliminates the need for physical boot devices (CD/DVD, USB) and reduces the installation overhead, especially for a large number of clients and operating systems. Probing the depths of PXE internals is beyond the scope of this chapter. A good starting point to learn more about PXE is https://en.wikipedia.org/wiki/Preboot_Execution_Environment.
A relatively straightforward way to produce a bootable USB drive with a Linux distribution of our choice is to use the open source tool UNetbootin (https://unetbootin.github.io). UNetbootin is a cross-platform utility, running on Windows, Linux, and macOS:
Here are the steps for creating a bootable USB drive with Ubuntu Desktop using UNetbootin. We assume the Ubuntu Desktop ISO image has been downloaded and UNetbootin is installed (in our case on macOS):
Now, let's look at how we can take the bootable media for a spin.
This step is optional.
Most Linux distributions have their ISO image available for download as live media. Once we have the bootable media created with our Linux distribution of choice, we can run a live environment of our Linux platform without actually installing it. In other words, we can evaluate and test the Linux distribution before deciding whether we want to install it. The live Linux operating system is loaded in the system memory (RAM) of our PC, without using any disk storage. We should make sure the PC has enough RAM to accommodate the minimum required memory of our Linux distribution.
We can run Linux in live mode in either of the following ways:
When booting the PC from a bootable media, we need to make sure the boot order in the BIOS is set to read our drive with the highest priority. On a Mac, we need to press the Option key immediately after the reboot start up chime and select our USB drive to boot from.
Upon reboot, the first splash screen of our Linux distribution should provide the option of running in live mode, as seen in the following illustration for Ubuntu Desktop (Try Ubuntu):
Next, let's take a look at the installation procedure of our Linux distro, using the bootable media.
We start the installation of our Linux distribution by booting the PC from the bootable media previously created. To ensure the system can boot from our drive (DVD or USB), we are sometimes required to change the boot order in the BIOS, especially if we boot from a USB drive. Most of the time, entering a system BIOS on a PC or laptop computer is done by pressing a Function key (or even the Delete key) immediately after powering on or restarting the machine. This key is usually mentioned at the bottom of the initial bootup screen.
In the following sections, we showcase the installation process of Ubuntu and CentOS using their ISO images. We choose the Desktop and Server versions for Ubuntu and highlight the main differences. CentOS comes in a single flavor, in essence, a server platform with an optional graphical user interface.
In each of the Linux installation sections, we also provide a brief guide on how to prepare a VM environment for the related Linux platform.
A VM is an isolated software abstraction of a physical machine. VMs are deployed on top of a hypervisor. A hypervisor provides the runtime provisioning and resource management of VMs. For the simple illustration of Linux VM installations, in this section, we limit ourselves to a couple of general-purpose hypervisors:
Both these hypervisors are cross-platform virtualization applications, and they run on Intel or AMD processor architectures on Windows, Linux, and macOS.
The difference between installing Linux on a VM compared to a physical machine is minor. The notable distinction is related to the VM sizing and configuration steps, making sure that the minimum system requirements of the Linux distribution are met.
In this section, we briefly illustrate the installation of Ubuntu Server LTS. If we plan to install Ubuntu in a VM, there are some preliminary steps required for provisioning the VM environment. Otherwise, we proceed directly to the Installation section.
In the following steps, we will create a VM based on Ubuntu Server—using VMware Workstation on macOS:
Let's look at the steps:
The remaining part of the Linux VM installation is identical to standard physical machine installation, shown in the following sections.
Here's the normal installation process for Ubuntu Server LTS, following the initial boot into setup mode:
After the system reboot, the login screen appears. We have completed the Ubuntu Server installation.
Next, let's take a look at a similar installation procedure, this time with the CentOS Linux distribution.
In this section, we briefly illustrate the installation of CentOS. If we plan to install CentOS in a VM, there are some preliminary steps required for provisioning the VM environment. Otherwise, we proceed directly with the Installation section.
In the following steps, we show the setup of a CentOS VM using Oracle VM VirtualBox on macOS. The choice of VirtualBox over VMware Workstation (used in the previous section with Ubuntu Server) is simply for showcasing the use of an alternative hypervisor:
a) Hostname and operating system (jupiter, CentOS Red Hat, 64-bit)
b) Memory size (4 GB)
c) Hard disk size (30 GB)
d) Hard disk file type (VDI VirtualBox Disk Image)
e) Storage on the physical hard disk (dynamically allocated)
f) File location and size (path to .vdi file, 30 GB)
At this stage, starting the VM initiates the CentOS installation.
Here's the normal installation process for CentOS, following the initial boot into setup mode:
a) Language support and localization (English, US)
b) Software selection (Server with GUI)
c) Device selection and storage configuration (Local media)
The following screenshot summarizes all this. The settings mostly reflect default values (Figure 1.13):
So far, we have learned how to perform a basic installation for two of the most common Linux distributions, Ubuntu and CentOS. Along the way, we created a bootable USB flash drive for our installation media, most commonly used for Linux PC platform installations. For both Linux distros, we briefly covered VM-specific Linux environments using the VMware Workstation and Oracle VM VirtualBox hypervisors.
In the following section, we'll learn how to install and run a Linux distribution on a Windows platform without the use of a standalone hypervisor.
Software developers and system administrators often face a tough decision in choosing the appropriate hardware and operating system platform for the specific requirements of their work or environment. In the past, Windows professionals were frequently reminded that some standard development tools, frameworks, or server components were available at large on Linux or macOS platforms, while lacking native support on Windows. Windows Subsystem for Linux (WSL) attempts to close this gap.
WSL is a Windows 10 platform feature that provides a native GNU/Linux runtime along with the Windows desktop environment. WSL enables the seamless deployment and integration of select Linux distributions on top of the Windows kernel, without the need for a dedicated hypervisor. With WSL enabled, you can easily install and run Linux as a native Windows application.
Important note
Without WSL, we could only deploy and run a Linux distribution on a Windows platform by using a standalone hypervisor, such as Hyper-V, Oracle VM VirtualBox, or VMware Workstation. WSL eliminates the need for a dedicated hypervisor. At the time of writing, WSL is a Windows kernel extension with a hypervisor embedded.
In this section, we provide the steps required to enable WSL and run an Ubuntu distribution on Windows. The following commands are executed on a Windows machine (or VM) in a PowerShell CLI with administrator privileges:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
We should get the result shown in Figure 1.16:
WSL 2 uses hypervisor technology. We need to enable the Virtual Machine Platform optional feature for Windows:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Important note
The Windows restart may feature an Update and Restart option. We need to make sure that the system gets updated upon restart.
wsl --set-default-version 2
This command may yield the message shown in Figure 1.18:
After installation, Ubuntu runs as a traditional Windows desktop command-line application.
WSL enables a swift adoption of Linux for a growing number of Windows professionals. As shown in this section, WSL is relatively easy to configure, and with WSL, there's no need for a dedicated hypervisor to run a Linux instance.
Important note
WSL currently doesn't support a GUI-driven Linux runtime. With WSL, we are exclusively interacting via the CLI.
In the following section, we take a quick look at the Linux graphical user interface and two of the most prominent Linux desktop environments: GNOME and KDE.
The Linux GUI is the desktop environment that allows users to interact with system-level components via windows, icons, menus, or other visual elements. For Linux users who look beyond the CLI, the choice of a Linux distribution may start with the desktop environment. Choosing a desktop environment is ultimately a matter of taste. And for some, the ultimate GUI represents the very extension of their eyes and hands at work.
Among the multitude of Linux desktop environments, there are two that stand out. Let's take a brief look at them.
With its current GNOME 3 (or GNOME Shell) iteration, this GUI platform is one of the most common Linux desktop environments. Nowadays, almost every major Linux distribution comes with GNOME as the default GUI. The Linux open source community also created GNOME Extensions, which overcomes some of the infamous shortcomings of GNOME and extends the desktop functionality to suit a variety of needs. When it's not the default desktop environment (such as with Linux Mint's Cinnamon desktop), GNOME can easily be installed and adapted.
At the time of writing, the latest distributions of Ubuntu (20.04 LTS) and CentOS (8) have GNOME as their default GUI.
Let's look at a real-world scenario requiring the installation of the latest GNOME desktop.
Ubuntu Server administrator:
Let's look at how to install it on Ubuntu:
sudo apt-get update -y
Now, we can upgrade with this:
sudo apt-get upgrade -y
apt-cache search ubuntu-desktop
sudo apt-get install ubuntu-desktop -y
systemctl status gdm
The expected response should be similar to Figure 1.22:
The GNOME 3 desktop is now installed and active on Ubuntu Server (Figure 1.23):
Next, let's take a look at the KDE desktop and a similar case study of enabling it on a Linux server platform.
Linux administrators usually look for a desktop environment that is relatively easy to use, lightweight, and efficient. KDE combines all of these attributes into a reliable and speedy desktop interface. Users familiar with Windows (up to version 7) would feel very much at home with KDE.
KDE has become a very robust desktop environment over the last few iterations, and versions of KDE have been released for almost every major Linux distribution.
If there's one ideal desktop for Linux administrators, KDE comes very close.
In this section, we take a fresh CentOS 8 installation with the default GNOME desktop enabled and replace it with KDE.
CentOS 8 administrator:
When we click the cogwheel in the CentOS 8 login screen, we get a list of the currently installed display servers. The default is Standard, a GNOME implementation of the Wayland compositor protocol for Linux desktop management. Wayland also has a KDE implementation in its latest KDE Plasma iteration at the time of writing (Figure 1.24):
Let's add the KDE Plasma desktop to our CentOS 8 server:
su
usermod -aG wheel packt
su - packt
sudo whoami
The command should prompt for the packt user password and then yield root.
sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y config-manager --enable PowerTools
sudo dnf -y group install kde-desktop
When the kde-desktop installation completes successfully, the output ends with a Complete! message prompt.
sudo systemctl reload gdm
reboot
We are now able to log in to CentOS 8 using the KDE Plasma desktop. Clicking the cogwheel in the login window, we can see the Plasma desktop available (Figure 1.26):
In this section, we briefly looked at the Linux GUI and showcased the installation of the GNOME and KDE desktop environments on Ubuntu Server and CentOS, respectively. Next, we provide a quick guide on setting up a Linux workstation with some insight into various software packages and applications that could benefit our everyday work.
In this section, we will learn how to set up and use a Linux platform as our primary workstation for day-to-day work. We choose the Ubuntu Desktop LTS distribution, but any other modern-day Linux distribution would fit the bill. We aim to showcase some basic user operations and workflows for building and using a general-purpose Linux desktop.
As we did in the previous sections about installing a Linux distribution, we start with a brief installation guide of Ubuntu Desktop LTS.
If we plan to install Ubuntu Desktop on a VM, there are some preliminary steps required for provisioning the VM environment. Otherwise, we proceed directly with the Installation section.
The VM provisioning procedure is very similar to the procedure described in the Installing Ubuntu section, with Ubuntu Server LTS.
We have to pay attention to the minimum system requirements of our Linux distribution and size the VM accordingly. In our case, Ubuntu Desktop requires a dual-core CPU, at least 4 GB RAM, and a minimum hard disk capacity of 25 GB. Since we plan to install a handful of additional software packages, we set the hard disk capacity to 60 GB (at least).
Ubuntu Desktop installation is relatively straightforward and requires very few user actions:
a) Keyboard layout
b) Installation type (normal versus minimal)
c) Localization and time zone
d) User configuration (account credentials) (Figure 1.28):
After the installation completes, the system reboot takes us to the Ubuntu Desktop login screen. At this point, we have completed the Ubuntu Desktop installation.
The default Ubuntu Desktop installation gets us a handful of software packages and productivity tools, enough for our general-purpose, day-to-day work. Here are just a few examples:
To view all currently installed applications, we click on the Ubuntu Software icon in the taskbar and then on the Installed tab. We could choose to remove (uninstall) any of these applications if we wanted to save disk space (Figure 1.29):
To browse or open any of these applications, click the grid icon (Show applications) at the bottom of the taskbar and then search for our application by beginning to type its name (Figure 1.30):
Next, let's take a look at how to install additional applications on our Ubuntu Linux workstation.
A power user may need additional software, tools, or utilities beyond the ones provisioned with the default Ubuntu Desktop installation. To add new applications, we click on the Ubuntu Software icon in the taskbar, followed by Explore, and then on the search icon. In the example illustrated in the following figure, we look for Visual Studio Code, a powerful code editor.
In general, when we decide on a particular application we want to install, we select the application, and this opens up a window for installing the related Ubuntu software package. Once we have completed the installation, the application shows up in the Installed section, where we can later uninstall it, if we choose to do so (Figure 1.31):
Different power users may look for a particular category of applications, tools, or utilities. Here are just a few of the most common types of productivity tools and applications used by the Linux user community. Some of them are readily available for download via the Ubuntu Software package management interface. Others can be downloaded from their related vendor websites.
Here are some commonly used applications for email and collaboration available for Ubuntu and other major Linux distributions:
Image editing tools abound for Linux. Here are just a few:
Most software development IDEs and tools are cross-platform these days. Ubuntu and many other Linux distros are not an exception in offering a vast array of such applications:
Virtualization and containerized workflows are in high demand now more than ever. All major hypervisors and container orchestration platforms are available for Linux as well:
Small-factor Linux PCs and appliances are often the ideal platforms for media servers. These are the most common media server applications generally available for almost any Linux distribution:
In our highly collaborative world, screen capture and recording tools always come in handy. Here are just a few:
Some of these applications may require a CLI for installation. Other applications are available either as a software package installer in the Ubuntu Software management user interface or via the APT package manager CLI (apt-get).
As we have previously shown, installing an application via the Ubuntu Software management interface is straightforward. Next, we take a look at Ubuntu's APT package manager platform and CLI.
APT is the default package manager in Ubuntu, and it's a platform interface for installing and removing software packages. As a core system library of Ubuntu, APT is a collection of tools and CLI programs helping with package and repository management: apt, apt-cache, and apt-get.
Important note
APT and DPKG: In essence, APT is a shim (frontend) to DPKG – the package manager of Debian Linux distributions. The apt CLI invokes the dpkg CLI under the hood.
Let's look at a few examples of using the apt-get and dpkg CLI tools for installing and managing software packages.
This scenario is from the perspective of a Java developer:
We assume an Ubuntu Desktop platform and OpenJDK version 14 for our case study.
Let's look at how to install OpenJDK (Java Development Kit):
sudo apt-get update -y
Next, proceed with the upgrade:
sudo apt-get upgrade -y
The preceding commands require superuser (sudo) privileges. We have to enter the password for our privileged (administrator) account. The -y option runs the apt-get command without requiring further user interaction.
sudo apt-get install -y openjdk-14-jre-headless
java --version
This command should yield the following response for our freshly installed OpenJDK (Figure 1.32):
dpkg --list openjdk-14-jre-headless
The preceding command yields a response similar to Figure 1.33:
Alternatively, we can use the apt-cache CLI to verify the status of the OpenJDK package:
apt-cache policy openjdk-14-jre-headless
The output is similar to Figure 1.34:
sudo apt-get remove openjdk-14-jre-headless
Or, you can use dpkg:
sudo dpkg --remove openjdk-14-jre-headless
To find out more about the dpkg CLI options, run dpkg --help. To get more information on the apt CLI tools, run man apt.
This scenario is from the perspective of a home theater enthusiast:
To install Plex Media Server (PMS) on Ubuntu, follow these steps:
sudo apt-get update -y
Next, run the upgrade:
sudo apt-get upgrade -y
According to the vendor's website, there are specific prerequisites regarding enabling the related repository, which we don't detail here.
sudo dpkg -i plexmediaserver_1.19.4.2935-79e214ead_amd64.deb
dpkg --list plexmediaserver
The preceding command results in a response similar to Figure 1.35:
sudo dpkg --remove plexmediaserver
To find out more about the dpkg CLI options, run dpkg --help.
In this chapter, we learned about Linux distributions, with a practical emphasis on choosing the right platform for our needs and performing the related installation procedures. Along the way, we showcased some hands-on, real-world scenarios that we thought are relevant for the topics covered, and to better capture the why or how of what we learned.
Throughout the chapter, the main emphasis has been on the Ubuntu and CentOS Linux distributions. In the spirit of the practical approach, we covered both physical and VM environments running Linux. We also took a short route through the Windows realm, where we touched upon WSL, a modern-day abstraction of Linux as a native Windows application.
We took the exercise of building a Linux workstation with some hands-on examples of how to customize the applications and tools we need for our everyday work.
With the skills learned in this chapter, we hope you'll have a better understanding of how to choose different flavors of Linux distros based on your needs. You've learned how to install and configure Linux on a variety of platforms: server, desktop, VM, and WSL. We also started exploring using the Linux command-line terminal for some of the tasks described in our case studies. You will use some of these skills throughout the rest of the book, but most importantly, you'll now be comfortable quickly deploying the Linux distribution of your choice and testing with it.
In today's increasingly rapid and agile development environments, Continuous Integration and Continuous Delivery (CI/CD) infrastructures make heavy use of Linux distros. Future chapters will introduce you to containerized workflows, and the knowledge gained in this chapter will help you with the design and deployment efforts of Linux containers.
Starting with the next chapter, we'll take a closer look at the various Linux subsystems, components, services, and applications. Chapter 2, The Linux Filesystem, will familiarize you with the Linux filesystem internals and related tools.
Here are a few questions and thought experiments that you may ponder, some based on the skills you have learned in this chapter, and others revealed in later parts of the book:
Hint: Software packages installed with GUI package management tools can be uninstalled from the same GUI (for instance, see Figure 1.36). Others can be removed using the package manager CLI tools (for instance, apt, dpkg, and rpm).
Hint: Use Vagrant, a tool for building and managing VM environments.
Hint: In the Installing Linux graphical user interfaces section, we showcased the addition of KDE side by side with GNOME. Each user can log in with their GUI desktop of choice (see Figure 1.31).
Hint: The Additional software packages section may provide some guidance.
Hint: Yes. Use wsl --import.
Hint: Create a bootable media of your new Linux distro and run the installer. Choose to upgrade when prompted. You may also use the command line. Check out the related CLI tools for your Linux distro (for instance, do-release-upgrade for Ubuntu).
3.128.94.171