Book Image

Mastering Linux Administration

By : Alexandru Calcatinge, Julian Balog
Book Image

Mastering Linux Administration

By: Alexandru Calcatinge, Julian Balog

Overview of this book

Linux plays a significant role in modern data center management and provides great versatility in deploying and managing your workloads on-premises and in the cloud. This book covers the important topics you need to know about for your everyday Linux administration tasks. The book starts by helping you understand the Linux command line and how to work with files, packages, and filesystems. You'll then begin administering network services and hardening security, and learn about cloud computing, containers, and orchestration. Once you've learned how to work with the command line, you'll explore the essential Linux commands for managing users, processes, and daemons and discover how to secure your Linux environment using application security frameworks and firewall managers. As you advance through the chapters, you'll work with containers, hypervisors, virtual machines, Ansible, and Kubernetes. You'll also learn how to deploy Linux to the cloud using AWS and Azure. By the end of this Linux book, you'll be well-versed with Linux and have mastered everyday administrative tasks using workflows spanning from on-premises to the cloud. If you also find yourself adopting DevOps practices in the process, we'll consider our mission accomplished.
Table of Contents (20 chapters)
Section 1: Linux Basic Administration
Section 2: Advanced Linux Server Administration
Section 3: Cloud Administration

Installing Linux graphical user interfaces

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.

Installing the GNOME desktop

Let's look at a real-world scenario requiring the installation of the latest GNOME desktop.

Ubuntu Server administrator:

I installed the latest version of Ubuntu Server LTS (20.04), and it looks like the GUI desktop is missing. How do I install the GNOME desktop on my Ubuntu Server?

Let's look at how to install it on Ubuntu:

  1. We start by making sure the current package lists and installed software packages are up to date. The following command updates the local package repository metadata for all configured sources:
    sudo apt-get update -y

    Now, we can upgrade with this:

    sudo apt-get upgrade -y
  2. To browse all the available ubuntu-desktop packages, run this:
    apt-cache search ubuntu-desktop
  3. We choose to install the ubuntu-desktop package (the first option in the preceding list):
    sudo apt-get install ubuntu-desktop -y
  4. The command will take a few minutes to complete. When done, we need to check the status of the GNOME Display Manager (GDM) service and make sure it shows an active (running) status:
    systemctl status gdm

    The expected response should be similar to Figure 1.22:

Figure 1.22 – Checking the status of GDM

Figure 1.22 – Checking the status of GDM

The GNOME 3 desktop is now installed and active on Ubuntu Server (Figure 1.23):

Figure 1.23 – The Ubuntu GNOME desktop login screen

Figure 1.23 – The Ubuntu GNOME desktop login screen

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.

Installing the KDE desktop

In this section, we take a fresh CentOS 8 installation with the default GNOME desktop enabled and replace it with KDE.

CentOS 8 administrator:

I installed the latest version of CentOS 8, choosing the "Server with GUI" option during setup. It looks like the CentOS 8 GUI runs the GNOME desktop. How do I install the KDE desktop on my CentOS 8 server?

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):

Figure 1.24 – The default CentOS 8 GNOME login screen

Figure 1.24 – The default CentOS 8 GNOME login screen

Let's add the KDE Plasma desktop to our CentOS 8 server:

  1. We log in to the CentOS 8 GUI and open the terminal, as suggested in the following illustration (Figure 1.25). Alternatively, we can simply SSH into the CentOS 8 server and run the commands in a similar CLI:
    Figure 1.25 – Opening the terminal in CentOS

    Figure 1.25 – Opening the terminal in CentOS

  2. The following commands have to be executed either as root or by a user account with sudoer privileges. Let's add our administrator user account (packt) to the sudoers group. We need to switch to root to run the required command:
  3. We get prompted for the root password (specified during the CentOS installation). See the Installing CentOS section for the related information. To add our packt user to the sudoers group, run this:
    usermod -aG wheel packt
  4. When the command finishes, switch to our newly minted sudoer account:
    su - packt
  5. Verify that our packt account does indeed have sudoer privileges:
    sudo whoami

    The command should prompt for the packt user password and then yield root.

  6. Next, proceed with the installation of the EPEL configuration files, enabling the related repositories:
    sudo rpm -Uvh
  7. Follow that by enabling the CentOS PowerTools repository (needed by KDE). We use dnf (Dandified YUM), a package manager CLI for RPM-based Linux distributions:
    sudo dnf -y config-manager --enable PowerTools
  8. Finally, we install the KDE Plasma desktop package group. The next command downloads a relatively large number of files (approximately 400 MB), and it may take a while:
    sudo dnf -y group install kde-desktop

    When the kde-desktop installation completes successfully, the output ends with a Complete! message prompt.

  9. Now that the KDE Plasma desktop has been installed, we can either reload the GNOME Desktop Manager (gdm) to account for the changes or simply reboot:
    sudo systemctl reload gdm
  10. If we have a CentOS 8 VM environment, a reboot is recommended:

    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):

    Figure 1.26 – Choosing the KDE Plasma desktop

    Figure 1.26 – Choosing the KDE Plasma desktop

  11. Once we're logged in, we can customize the KDE Plasma desktop to our preference (Figure 1.27):
Figure 1.27 – Customizing the KDE Plasma desktop

Figure 1.27 – Customizing the KDE Plasma desktop

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.