Explore 1.5M+ audiobooks & ebooks free for days

Only $12.99 CAD/month after trial. Cancel anytime.

Mastering Linux System Administration
Mastering Linux System Administration
Mastering Linux System Administration
Ebook1,266 pages10 hours

Mastering Linux System Administration

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Achieve Linux system administration mastery with time-tested and proven techniques 

In Mastering Linux System Administration, Linux experts and system administrators Christine Bresnahan and Richard Blum deliver a comprehensive roadmap to go from Linux beginner to expert Linux system administrator with a learning-by-doing approach. Organized by do-it-yourself tasks, the book includes instructor materials like a sample syllabus, additional review questions, and slide decks. 

Amongst the practical applications of the Linux operating system included within, you’ll find detailed and easy-to-follow instruction on: 

  • Installing Linux servers, understanding the boot and initialization processes, managing hardware, and working with networks 
  • Accessing the Linux command line, working with the virtual directory structure, and creating shell scripts to automate administrative tasks 
  • Managing Linux user accounts, system security, web and database servers, and virtualization environments 

Perfect for entry-level Linux system administrators, as well as system administrators familiar with Windows, Mac, NetWare, or other UNIX systems, Mastering Linux System Administration is a must-read guide to manage and secure Linux servers. 

LanguageEnglish
PublisherWiley
Release dateJun 29, 2021
ISBN9781119794462
Mastering Linux System Administration

Read more from Christine Bresnahan

Related to Mastering Linux System Administration

Related ebooks

Operating Systems For You

View More

Reviews for Mastering Linux System Administration

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Mastering Linux System Administration - Christine Bresnahan

    Mastering Linux® System Administration

    Christine Bresnahan

    Richard Blum

    Logo: Wiley

    Copyright © 2021 by John Wiley & Sons, Inc. All rights reserved.

    Published by John Wiley & Sons, Inc., Hoboken, New Jersey.

    Published simultaneously in Canada.

    ISBN: 978‐1‐119‐79445‐5

    ISBN: 978‐1‐119‐79447‐9 (ebk.)

    ISBN: 978‐1‐119‐79446‐2 (ebk.)

    No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per‐copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750‐8400, fax (978) 750‐4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748‐6011, fax (201) 748‐6008, or online at http://www.wiley.com/go/permission.

    Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

    For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762‐2974, outside the United States at (317) 572‐3993 or fax (317) 572‐4002.

    Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.

    Library of Congress Control Number: 2021938273

    TRADEMARKS: WILEY and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Linux is a registered trademark of Linus Torvalds. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.

    Cover Image: © gorodenkoff/Getty Images

    Cover Design: Wiley

    To the Lord God Almighty, in whom are hidden all the treasures of wisdom and knowledge.

    —Colossians 2:3

    Acknowledgments

    First, all glory and praise go to God, who through His Son, Jesus Christ, makes all things possible and gives us the gift of eternal life.

    Many thanks go to the fantastic team of people at John Wiley & Sons for their outstanding work on this project. Thanks to Kenyon Brown, the acquisitions editor, for offering us the opportunity to work on this book. Also, thanks to Kathryn Duggan, the project editor, for keeping things on track and making this book more presentable. Thanks, Kathi, for all your hard work and diligence. The technical editor, Jason Eckert, did a wonderful job of double‐checking all the work in the book, plus making suggestions to improve the content. Thanks to Barath Kumar Rajasekaran and his team for their endless patience and diligence to make our work readable. We would also like to thank Carole Jelen at Waterside Productions, Inc., for arranging this opportunity for us, and for helping us out in our writing careers.

    Christine would like to thank her husband, Timothy, for his encouragement, patience, and willingness to listen, even when he has no idea what she is talking about. Rich would like to thank his wife, Barbara, for the life‐sustaining baked goods she readily prepared to help him keep up his energy while writing!

    About the Authors

    Christine Bresnahan started working with computers more than 30 years ago in the IT industry as a system administrator. Christine is an adjunct professor at Ivy Tech Community College where she teaches Linux certification and Python programming classes. She also writes books and produces instructional resources. During her downtime, Christine enjoys spending time with her husband and family, hiking, and gardening.

    Richard Blum has worked in the IT industry for more than 30 years as both a systems and network administrator, working with lots of different operating systems (including Linux, of course). Over the years, he's also volunteered for several nonprofit organizations to help support small networks that had little financial support. Rich is the author of many Linux‐based books for total Linux geeks and teaches online courses in Linux and web programming. When he's not busy being a computer nerd, Rich enjoys playing piano and bass guitar and spending time with his wife, Barbara, and their two daughters, Katie Jane and Jessica.

    About the Technical Editor

    Jason W. Eckert is an experienced technical trainer, systems architect, software engineer, and best‐selling author in the technology industry. With 45 industry certifications, more than 30 years of technology and programming experience, 4 published apps, and 25 published textbooks covering UNIX, Linux, Security, Windows Server, Microsoft Exchange Server, PowerShell, BlackBerry Enterprise Server, and video game development, Mr. Eckert brings his expertise to every class that he teaches at triOS College. He was also named 2019 Outstanding Train‐the‐Trainer from the Computing Technology Industry Association (CompTIA). For more information about Mr. Eckert, visit jasoneckert.net.

    Introduction

    Over the last few decades, the Linux operating system has evolved from being a hobbyist curiosity to becoming the operating system of choice for most servers on the Internet. The explosion in popularity of cloud computing is due to the robustness of Linux servers, and knowing how to install, configure, and manage Linux servers has become a necessary skill for most data center system administrators.

    This book covers what you'll need to know to work in a Linux server environment. One of the difficulties of working on Linux servers is that more often than not, you don't have access to a graphical desktop, so knowing how to interact with the server using text commands is a crucial skill to have for Linux system administrators. This book covers all aspects of Linux server management from the command line, from installing the system to configuring and monitoring common software packages found on Linux servers.

    One of the confusing aspects of Linux is that there are many different flavors, or distributions, of Linux available. However, there are two main Linux server distributions that have risen to the top in popularity in professional data centers. This book covers how to interact with both Ubuntu and Red Hat servers, providing separate instructions for each server environment when necessary.

    Who Should Read This Book

    This book is intended for the classroom environment, so the primary audience for the book is educators working at the high school, college, or university level. The book provides sufficient exercises, quizzes, and instructor material to create a one‐semester course in Linux system administration.

    That said, this book can also be used as a standard reference for any individual wanting to learn more about Linux system administration. There are several ways you can use this book. The most straightforward is to start at the beginning and follow all the steps to install, configure, and use a Linux server as described over the course of the book. Alternately, you can skip around from chapter to chapter and follow only the steps of the individual chapters. The book will also make for a handy reference guide as you work in a Linux server environment, performing your day‐to‐day duties in supporting your system users.

    NOTE This book provides Instructor Materials that include PowerPoints for each chapter, a course syllabus, and bonus questions. Please visit the book page at www.wiley.com.

    What You Will Learn

    This book covers the basics of installing a Linux server, working in a command‐line environment, and managing users, hardware, and software. The book starts by covering the basic Linux skills you'll need to install and work in a Linux server and then goes on to cover more intermediate skills such as configuring and troubleshooting user accounts, storage devices, and networks. Finally, the book finishes by providing advanced system administration skills in writing shell script programs, setting up a web or database server, and even using virtualization in the Linux environment.

    What You Need

    To follow along in the chapters and complete the exercises in this book, you'll need some type of Linux server environment. The book specifically covers both the Ubuntu and Red Hat servers. If you intend to use the Red Hat server environment, you don't necessarily need to purchase a commercial copy of Red Hat Enterprise Linux. Instead, you can use the open source CentOS Linux server, which is an authorized copy of Red Hat intended for the open source world. At the time of this writing, the current versions of each are Ubuntu 20.04LTS and CentOS 8.1. These are the versions used in the exercises; if you opt to use newer versions of either server, you may experience different results in some exercises.

    The best way to learn Linux is to install it on a separate physical system. If you don't plan on having your server host thousands of clients, you can use any old Windows workstation to install Linux (the book covers how to do that). Just remember that if you replace an existing Windows workstation with Linux, you will lose all data currently on the workstation, so make sure you back up any important data first.

    Alternatively, you can load a virtualization software package, such as VirtualBox, in an existing Windows workstation. The virtualization software allows you to install and run the Linux server software in a virtual environment on top of Windows, sharing the hardware and disk space with your Windows workstation. In this setup, you don't need to worry about your Windows workstation data—it will remain safely separate from the Linux server.

    The Mastering Series

    The Mastering series from Wiley provides outstanding instruction for readers with intermediate and advanced skills, in the form of top‐notch training and development for those already working in their field and clear, serious education for those aspiring to become pros. Every Mastering book features the following:

    The Wiley by professionals for professionals commitment. Mastering authors are themselves practitioners, with plenty of credentials in their areas of specialty.

    A practical perspective for a reader who already knows the basics—someone who needs solutions, not a primer.

    Real‐World Scenarios, ranging from case studies to interviews, that show how the tool, technique, or knowledge presented is applied in actual practice.

    Skill‐based instruction, with chapters organized around real tasks rather than abstract concepts or subjects.

    Self‐review test Master It problems and questions, so you can be certain you're equipped to do the job right.

    How to Contact Wiley or the Authors

    Sybex strives to keep you supplied with the latest tools and information you need for your work. If you believe you have found an error in this book and it is not listed on the book's web page, you can report the issue to the Wiley customer support team at wileysupport.com.

    You can email the authors with your comments or questions at [email protected].

    Part 1

    Basic Admin Functions

    Chapter 1: Understanding the Basics

    Chapter 2: Installing an Ubuntu Server

    Chapter 3: Installing and Maintaining Software in Ubuntu

    Chapter 4: Installing a Red Hat Server

    Chapter 5: Installing and Maintaining Software in Red Hat

    Chapter 6: Working with the Shell

    Chapter 7: Exploring Linux File Management

    Chapter 8: Working with Text Files

    Chapter 1

    Understanding the Basics

    The Linux operating system has taken the world by storm. Whether it's embedded Linux software operating in phones and refrigerators or full‐blown Linux servers running famous Internet sites, you can find Linux systems just about everywhere. If you've chosen (or have been chosen) to be a Linux system administrator, the task before you can seem daunting at first. But don't panic—while complex, the Linux system is organized and structured. Just knowing the basics of how Linux works will go a long way in helping you with your goals of becoming a Linux system administrator. This chapter walks you through the basics of what Linux is and explains the different versions of Linux that are available.

    IN THIS CHAPTER, YOU WILL LEARN TO

    List the components of a standard Linux system

    Explain how GNU utilities are used in Linux

    Describe the various Linux user interface environments

    Explain why there are different Linux distributions

    What Is Linux?

    If you've never worked with Linux, you may be confused as to why there are so many different versions of it available. You've probably heard various terms such as distribution, LiveDVD, and GNU when looking at Linux packages, and may have been confused. Wading through the world of Linux for the first time can be a tricky experience. This chapter takes some of the mystery out of the Linux system before you start working on commands and scripts.

    For starters, these four main parts make up a Linux system:

    The Linux kernel

    The GNU utilities

    A user interface

    Application software

    Each of these four parts has a specific job in the Linux system. Figure 1.1 shows a basic diagram of how the parts fit together on top of the computer hardware to create the overall Linux system.

    Snapshot of the Linux system

    FIGURE 1.1 The Linux system

    This section describes these four main parts in detail and gives you an overview of how they work together to create a complete Linux system.

    Looking into the Linux Kernel

    The core of the Linux system is the kernel. The kernel controls all of the hardware and software on the computer system, allocating hardware when necessary and executing software when required.

    If you've been following the Linux world at all, no doubt you've heard the name Linus Torvalds. Linus is the person responsible for creating the first Linux kernel software while he was a student at the University of Helsinki. He intended it to be a copy of the Unix system, at the time a popular operating system used at many universities.

    After developing the Linux kernel, Linus released it to the Internet community and solicited suggestions for improving it. This simple process started a revolution in the world of computer operating systems. Soon Linus was receiving suggestions from students as well as professional programmers from around the world.

    Allowing anyone to change programming code in the kernel would result in complete chaos. To simplify things, Linus acted as a central point for all improvement suggestions. It was ultimately Linus's decision whether to incorporate suggested code in the kernel. This same concept is still in place with the Linux kernel code, except that instead of just Linus controlling the kernel code, a team of developers has taken on the task.

    The kernel is primarily responsible for these four main functions:

    System memory management

    Software program management

    Hardware management

    Filesystem management

    The following sections explore each of these functions in more detail.

    SYSTEM MEMORY MANAGEMENT

    One of the primary functions of the operating system kernel is memory management. Not only does the kernel manage the physical memory available on the server, but it can also create and manage virtual memory, or memory that does not actually exist.

    It does this by using space on the hard disk, called the swap space. The kernel swaps the contents of virtual memory locations back and forth from the swap space to the actual physical memory. This allows the system to think there is more memory available than what physically exists (shown in Figure 1.2).

    Snapshot of the Linux system memory map

    FIGURE 1.2 The Linux system memory map

    The memory locations are grouped into blocks called pages. The kernel locates each page of memory either in the physical memory or in the swap space. The kernel then maintains a table of the memory pages that indicates which pages are in physical memory and which pages are swapped out to disk.

    The kernel keeps track of which memory pages are in use and automatically copies memory pages that have not been accessed for a period of time to the swap space area (called swapping out), even if there's other memory available. When a program wants to access a memory page that has been swapped out, the kernel must make room for it in physical memory by swapping out a different memory page and swapping in the required page from the swap space. Obviously, this process takes time and can slow down a running process. The process of swapping out memory pages for running applications continues for as long as the Linux system is running.

    Real World Scenario

    LOOKING AT MEMORY

    There are a couple of simple commands you can use to get an idea of just how your Linux system is managing memory. While we'll be exploring these commands in more detail later in the book, here's a quick exercise for you to get started exploring your Linux system:

    Log into your Linux system. (If you don't have a Linux system available yet, you can come back to here after going through either Chapter 2, Installing an Ubuntu Server, or Chapter 4, Installing a Red Hat Server.)

    From the command prompt, enter the command free. You should see something similar to this output:

    $ free              total        used        free      shared  buff/cache  availableMem:        2035504      135668    1449568        1048      450268    1742704Swap:      2097148          0    2097148

    The output from the free command shows the total amount of physical memory installed on the system, as well as the amount of swap space currently configured.

    The free command just provides an overview of the memory for your Linux system. For a more detailed look, enter the command cat /proc/meminfo. You should see a long listing, similar to this:

    $ cat /proc/meminfoMemTotal:        2035504 kBMemFree:        1449632 kBMemAvailable:    1742352 kBBuffers:          25452 kBCached:          386028 kBSwapCached:            0 kBActive:          166036 kBInactive:        290704 kBActive(anon):      51796 kBInactive(anon):      128 kBActive(file):    114240 kBInactive(file):  290576 kBUnevictable:      18640 kBMlocked:          18640 kBSwapTotal:      2097148 kBSwapFree:        2097148 kBDirty:              156 kBWriteback:            0 kBAnonPages:        63940 kBMapped:            63344 kBShmem:              1048 kBKReclaimable:      38664 kBSlab:              74316 kBSReclaimable:      38664 kBSUnreclaim:        35652 kBKernelStack:        2044 kBPageTables:        1268 kBNFS_Unstable:          0 kBBounce:                0 kBWritebackTmp:          0 kBCommitLimit:    3114900 kBCommitted_AS:    376812 kBVmallocTotal:  34359738367 kBVmallocUsed:      27676 kBVmallocChunk:          0 kBPercpu:              516 kBHardwareCorrupted:    0 kBAnonHugePages:        0 kBShmemHugePages:        0 kBShmemPmdMapped:        0 kBFileHugePages:        0 kBFilePmdMapped:        0 kBCmaTotal:              0 kBCmaFree:              0 kBHugePages_Total:      0HugePages_Free:        0HugePages_Rsvd:        0HugePages_Surp:        0Hugepagesize:      2048 kBHugetlb:              0 kBDirectMap4k:      90048 kBDirectMap2M:    2007040 kB$

    The kernel continually updates the meminfo file to show exactly what's going on in memory at that moment in time, so the file constantly changes.

    SOFTWARE PROGRAM MANAGEMENT

    The Linux operating system calls a running program a process. A process can run in the foreground, displaying output on a display, or it can run in background, behind the scenes. The kernel controls how the Linux system manages all the processes running on the system.

    The kernel creates the first process, called the init process, to start all other processes on the system. When the kernel starts, it loads the init process into virtual memory. As the kernel starts each additional process, it gives it a unique area in virtual memory to store the data and code that the process uses.

    There are a few different types of init process implementations available in Linux, but these days, the two most popular are as follows:

    SysVinit—The SysVinit (SysV) initialization method was the original method used by Linux and was based on the Unix System V initialization method. Though it is not used by many Linux distributions these days, you still may find it around in older Linux distributions.

    Systemd—The systemd initialization method was created in 2010 and has become the most popular initialization and process management system used by Linux distributions.

    The SysVinit initialization method used a concept called runlevels to determine what processes to start. The runlevel defines the state of the running Linux system and what processes should run in each state. Table 1.1 shows the different runlevels associated with the SysVinit initialization method.

    TABLE 1.1: The SysVinit Runlevels

    The /etc/inittab file defines the default runlevel for a system. The processes that start for specific runlevels are defined in subdirectories of the /etc/rc.d directory. You can view the current runlevel at any time using the runlevel command, as shown here:

    $ runlevel N 5 $

    The systemd initialization method became popular because it has the ability to start processes based on different events such as these:

    When the system boots

    When a particular hardware device is connected

    When a service is started

    When a network connection is established

    When a timer has expired

    The systemd method determines what processes to run by linking events to unit files. Each unit file defines the programs to start when the specified event occurs. The systemctl program allows you to start, stop, and list the unit files currently running on the system.

    The systemd method groups unit files together into targets. A target defines a specific running state of the Linux system, similar to the SysVinit runlevel concept. At system startup, the default.target unit defines all the unit files to start. You can view the current default target using the systemctl command.

    $ systemctl get-default graphical.target $

    The graphical.target target defines the processes to start when a multiuser graphical environment is running, similar to the old SysVinit runlevel 5.

    Real World Scenario

    EXAMINING PROCESSES

    In Chapter 14, Working with Processes and Jobs, you'll see how to use the ps command to view the processes currently running on the Linux system. You can use it now to take a quick peek at what programs are currently running on your Linux system.

    Log into your Linux system. (If you don't have a Linux system available yet, you can come back to here after going through either Chapter 2 or Chapter 4.)

    At the command prompt, enter the command psax. You should see something similar to this output:

    $ ps ax    PID TTY      STAT  TIME COMMAND      1 ?        Ss    0:00 /sbin/init maybe-ubiquity      2 ?        S      0:00 [kthreadd]      3 ?        I<    0:00 [rcu_gp]      4 ?        I<    0:00 [rcu_par_gp]      5 ?        I      0:00 [kworker/0:0-memcg_kmem_cache]      6 ?        I<    0:00 [kworker/0:0H-kblockd]      7 ?        I      0:00 [kworker/0:1-events]      8 ?        I      0:00 [kworker/u2:0-events_power_efficient]. . .    1033 tty1    S      0:00 -bash  1054 tty1    R+    0:00 ps ax$

    We've just shown the start of the listing, along with the last two lines, but you should see a long list of different programs running on your Linux system (including the ps command that you started). The kernel is keeping track of all those programs!

    HARDWARE MANAGEMENT

    Still another responsibility for the kernel is hardware management. Any device that the Linux system must communicate with needs driver code inserted inside the kernel code. The driver code allows the kernel to pass data back and forth to the device, acting as a middleman between applications and the hardware. There are two methods used for inserting device driver code in the Linux kernel.

    Drivers compiled in the kernel

    Driver modules added to the kernel

    Previously, the only way to insert device driver code was to recompile the kernel. Each time you added a new device to the system, you had to recompile the kernel code. This process became even more inefficient as Linux kernels supported more hardware. Fortunately, Linux developers devised a better method to insert driver code into the running kernel.

    Programmers developed the concept of kernel modules to allow you to insert driver code into a running kernel without having to recompile the kernel. Also, a kernel module could be removed from the kernel when the device was finished being used. This greatly simplified and expanded using hardware with Linux.

    The Linux system identifies hardware devices as special files, called device files. There are three different classifications of device files.

    Character

    Block

    Network

    Character device files are for devices that can only handle data one character at a time. Most types of modems and terminals are created as character files. Block files are for devices that can handle data in large blocks at a time, such as disk drives.

    The network file types are used for devices that use packets to send and receive data. This includes network cards and a special loopback device that allows the Linux system to communicate with itself using common network programming protocols.

    Linux creates special files, called nodes, for each device on the system. All communication with the device is performed through the device node. Each node has a unique number pair that identifies it to the Linux kernel. The number pair includes a major and a minor device number. Similar devices are grouped into the same major device number. The minor device number is used to identify a specific device within the major device group.

    FILESYSTEM MANAGEMENT

    Unlike some other operating systems, the Linux kernel can support different types of filesystems to read and write data to and from hard drives. Besides having more than a dozen filesystems of its own, Linux can read and write to and from filesystems used by other operating systems, such as Microsoft Windows. The kernel must be compiled with support for all types of filesystems that the system will use. Table 1.2 lists the standard filesystems that a Linux system can use to read and write data.

    TABLE 1.2: Linux Filesystems

    Any hard drive that a Linux server accesses must be formatted using one of the filesystem types listed in Table 1.2.

    The Linux kernel interfaces with each filesystem using the Virtual File System (VFS). This provides a standard interface for the kernel to communicate with any type of filesystem. VFS caches information in memory as each filesystem is mounted and used.

    The GNU Utilities

    Besides having a kernel to control hardware devices and launch programs, a computer operating system needs utilities to perform standard functions, such as controlling files and programs. While Linus created the Linux system kernel, he had no system utilities to run on it. Fortunately for him, at the same time he was working, a group of people were working together on the Internet trying to develop a standard set of computer system utilities that mimicked the popular Unix operating system.

    The GNU organization (GNU stands for GNU's Not Unix) developed a complete set of Unix utilities but had no kernel system to run them on. These utilities were developed under a software philosophy called open source software (OSS).

    The concept of OSS allows programmers to develop software and then release it to the world with no licensing fees attached. Anyone can use the software, modify it, or incorporate it into their own system without having to pay a license fee. Uniting Linus's Linux kernel with the GNU operating system utilities created a complete, functional, free operating system.

    While the bundling of the Linux kernel and GNU utilities is often just called Linux, you will see some Linux purists on the Internet refer to it as the GNU/Linux system to give credit to the GNU organization for its contributions to the cause.

    The GNU project was mainly designed for Unix system administrators to have a Unix‐like environment available. This focus resulted in the project porting many common Unix system command‐line utilities. The core bundle of utilities supplied for Linux systems is called the coreutils package.

    The GNU coreutils package consists of these three parts:

    Utilities for handling files

    Utilities for manipulating text

    Utilities for managing processes

    Each of these three main groups of utilities contains several utility programs that are invaluable to the Linux system administrator and programmer.

    Linux User Interfaces

    Having a world‐class operating system that can manage your computer hardware and software is great, but you also need some way to communicate with it. Back in the old days of computers, you communicated with the mainframe computer by punching holes into cards, feeding them into a card reader, and then waiting for the output to appear on a printer. Fortunately, those days are long gone.

    Thanks to the Apple macOS and Microsoft Windows operating systems, these days most desktop computer users expect some type of graphical display to interact with their system. Linux doesn't disappoint, offering a plethora of graphical desktops you can choose from. The following sections describe a few of the more popular ones.

    THE X WINDOW SOFTWARE

    Two basic elements control your video environment—the video card in your PC and your monitor. To display fancy graphics on your computer, the Linux software needs to know how to talk to both of them. The X Window software is the core element in presenting graphics.

    The X Window software is a low‐level program that works directly with the video card and monitor in the PC and controls how Linux applications can present fancy windows and graphics on your computer.

    Linux isn't the only operating system that uses X Window; there are versions written for many different operating systems. In the Linux world, there are a few different software packages that can implement it. There are two X Window packages that are most commonly used in Linux:

    X.org

    Wayland

    The X.org package is the older of the two, based on the original Unix X Window System version 11 (often called X11). More Linux distributions are migrating to the newer Wayland software, which is more secure and easier to maintain.

    When you first install a Linux distribution, it attempts to detect your video card and monitor and then creates an X Window configuration file that contains the required information. During installation, you may notice a time when the installation program scans your monitor for supported video modes. Sometimes this causes your monitor to go blank for a few seconds. Because there are lots of different types of video cards and monitors out there, this process can take a little while to complete.

    The core X Window software produces a graphical display environment, but nothing else. While this is fine for running individual applications, it is not too useful for day‐to‐day computer use. There is no desktop environment allowing users to manipulate files or launch programs. To do that, you need a desktop environment on top of the X Window system software.

    THE KDE PLASMA DESKTOP

    The K Desktop Environment (KDE) was first released in 1996 as an open source project to produce a graphical desktop similar to the Microsoft Windows environment. The KDE desktop incorporates all of the features you are probably familiar with if you are a Windows user. Figure 1.3 shows the current version, called KDE Plasma, running in the openSUSE Linux distribution.

    Snapshot of the KDE Plasma desktop on an openSUSE Linux system

    FIGURE 1.3 The KDE Plasma desktop on an openSUSE Linux system

    The KDE Plasma desktop allows you to place both application and file icons in a special area on the desktop. If you single‐click an application icon, the Linux system starts the application. If you single‐click a file icon, the KDE desktop attempts to determine what application to start to handle the file.

    The bar at the bottom of the desktop is called the Panel. The Panel consists of these four parts:

    The KDE Start menu—Much like the Windows Start menu, the KDE Start menu contains links to start installed applications.

    Program shortcuts—These are quick links to start applications directly from the Panel.

    The taskbar—The taskbar shows icons for applications currently running on the desktop.

    Applets—These are small applications that have an icon in the Panel that often can change depending on information from the application.

    All of the Panel features are similar to what you would find in Windows. In addition to the desktop features, the KDE project has produced a wide assortment of applications that run in the KDE environment.

    THE GNOME DESKTOP

    The GNU Network Object Model Environment (GNOME) is another popular Linux desktop environment. First released in 1999, GNOME has become the default desktop environment for many Linux distributions (the most popular being Red Hat Linux).

    GNOME CONTROVERSY

    The GNOME desktop underwent a radical change with version 3, released in 2011. It departed from the standard look and feel of most desktops using standard menu bars and taskbars to make the interface more user‐friendly across multiple platforms, such as tablets and mobile phones. This change led to controversy (see the Other Desktops section), but slowly many Linux enthusiasts accepted the new look and feel of the GNOME 3 desktop.

    Figure 1.4 shows the standard GNOME desktop used in the Ubuntu Linux distribution.

    The GNOME 3 desktop cleans up the desktop interface by reducing the available menus to just these three:

    Activities—Displays favorites, as well as any running application icons

    Calendar—Shows the current date/time, along with any system notification messages

    System—Shows network connections, system settings, and options to restart the system

    The GNOME 3 desktop was designed to work on multiple types of devices, so you'll find there aren't a lot of menus. To launch applications, you must search for them using the Activities Overview, which is a search feature from the Activities menu.

    Snapshot of a GNOME 3 desktop on an Ubuntu Linux system

    FIGURE 1.4 A GNOME 3 desktop on an Ubuntu Linux system

    Not to be outdone by KDE, the GNOME developers have also produced a host of graphical applications that integrate with the GNOME desktop.

    OTHER DESKTOPS

    One of the main features of Linux is choice, and nowhere is that more evident than in the graphical desktop world. There are a plethora of different types of graphical desktops available in the Linux world. If you're not happy with the default desktop in your Linux distribution, it usually doesn't take much effort to change it to something else.

    When the GNOME desktop project radically changed its interface in version 3, many Linux developers who preferred the look and feel of GNOME version 2 created spin‐off versions based on GNOME 2. Of these, two became somewhat popular.

    Cinnamon—The Cinnamon desktop was developed in 2011 by the Linux Mint distribution in an attempt to continue development of the original GNOME 2 desktop. It's now available as an option in several Linux distributions, including Ubuntu, Fedora, and openSUSE.

    MATE—The MATE desktop was also developed in 2011 by an Arch Linux user who disliked the switch to GNOME 3. However, it incorporates a few features of GNOME 3 (such as replacing the taskbar) but maintains the overall look and feel of GNOME 2.

    Figure 1.5 shows the Cinnamon desktop as it appears in the Linux Mint distribution.

    The downside to these fancy graphical desktop environments is that they require a fair amount of system resources to operate properly. In the early days of Linux, a hallmark and selling feature of Linux was its ability to operate on older, less powerful PCs that the newer Microsoft desktop products couldn't run on. However, with the popularity of KDE Plasma and GNOME 3 desktops, this has changed, as it takes just as much memory to run a KDE Plasma or GNOME 3 desktop as the latest Microsoft desktop environment.

    Snapshot of the Cinnamon desktop from Linux Mint

    FIGURE 1.5 The Cinnamon desktop from Linux Mint

    If you have an older PC, don't be discouraged. The Linux developers have banded together to take Linux back to its roots. They've created several low‐memory–oriented graphical desktop applications that provide basic features that run perfectly fine on older PCs.

    While these graphical desktops don't have a plethora of applications designed around them, they still run many basic graphical applications that support features such as word processing, spreadsheets, databases, drawing, and, of course, multimedia support.

    Table 1.3 shows some of the smaller Linux graphical desktop environments that can be used on lower‐powered PCs and laptops.

    TABLE 1.3: Other Linux Graphical Desktops

    These graphical desktop environments are not as fancy as the KDE Plasma and GNOME 3 desktops, but they provide basic graphical functionality just fine. Figure 1.6 shows what the Xfce desktop used in the MX Linux distribution looks like.

    Snapshot of the Xfce desktop as seen in the MX Linux distribution

    FIGURE 1.6 The Xfce desktop as seen in the MX Linux distribution

    If you are using an older PC, try a Linux distribution that uses one of these desktops and see what happens. You may be pleasantly surprised.

    THE COMMAND‐LINE INTERFACE

    While having a fancy graphical desktop interface is nice, there are drawbacks. The extra processing power required to interact with the graphics card takes away crucial CPU time that can be used for other programs. Nowhere is this more important than in a server environment.

    Because of that, many Linux servers don't load a graphical desktop and instead rely on a text‐based interface, called the command‐line interface (CLI). The CLI provides a way for users to start programs, manage files on the filesystem, and manage processes running on the Linux system using simple text commands. The CLI is produced by a program called a shell. The shell allows you to enter text commands, and then it interprets the commands and then executes them in the kernel.

    The shell contains a set of internal commands that you use to control things such as copying files, moving files, renaming files, displaying the programs currently running on the system, and stopping programs running on the system. Besides the internal commands, the shell also allows you to enter the name of a program at the command prompt. The shell passes the program name off to the kernel to start it.

    You can also group shell commands into files to execute as a program. Those files are called shell scripts. Any command that you can execute from the command line can be placed in a shell script and run as a group of commands. This provides great flexibility in creating utilities for commonly run commands, or processes that require several commands grouped together.

    There are quite a few Linux shells available to use on a Linux system. Different shells have different characteristics, some being more useful for creating scripts and some being more useful for managing processes. The default shell used in all Linux distributions is the Bash Shell. The Bash Shell was developed by the GNU project as a replacement for the standard Unix shell, called the Bourne shell (after its creator). The Bash Shell name is a play on this wording, referred to as the Bourne again shell.

    In addition to the Bash Shell, there are several other popular shells you could run into in a Linux environment. Table 1.4 lists the more popular ones.

    TABLE 1.4: Linux Shells

    Most Linux distributions include more than one shell, although usually they pick one of them to be the default. If your Linux distribution includes multiple shells, feel free to experiment with different shells and see which one fits your needs.

    Linux Distributions

    Now that you have seen the four main components required for a complete Linux system, you may be wondering how you are going to get them all put together to make a Linux system. Fortunately, there are people who have already done that for you.

    A complete Linux system package is called a distribution. There are lots of different Linux distributions available to meet just about any computing requirement you could have. Most distributions are customized for a specific user group, such as business users, multimedia enthusiasts, software developers, or average home users. Each customized distribution includes the software packages required to support specialized functions, such as audio‐ and video‐editing software for multimedia enthusiasts, or compilers and integrated development environments (IDEs) for software developers.

    The different Linux distributions are often divided into two categories.

    Core Linux distributions

    Specialized distributions

    The following sections describe these different types of Linux distributions and show some examples of Linux distributions in each category.

    Core Linux Distributions

    A core Linux distribution contains a kernel, one or more graphical desktop environments, and just about every Linux application that is available, precompiled for the kernel. It provides one‐stop shopping for a complete Linux installation. Table 1.5 shows some of the more popular core Linux distributions.

    TABLE 1.5: Core Linux Distributions

    In the early days of Linux, a distribution was released as a set of floppy disks. You had to download groups of files and then copy them onto disks. It would usually take 20 or more disks to make an entire distribution! Needless to say, this was a painful experience.

    Nowadays, Linux distributions are released as an ISO image file. The ISO image file is a complete disk image of a DVD as a single file. You use a software application to either burn the ISO image file onto a DVD or create a bootable USB stick. You then just boot your workstation from the DVD or USB stick to install Linux. This makes installing Linux much easier.

    However, beginners still often run into problems when they install one of the core Linux distributions. To cover just about any situation in which someone might want to use Linux, a single distribution has to include lots of application software. They include everything from high‐end Internet database servers to common games.

    While having lots of options available in a distribution is great for Linux geeks, it can become a nightmare for beginning Linux users. Most core distributions ask a series of questions during the installation process to determine which applications to load by default, what hardware is connected to the PC, and how to configure the hardware. Beginners often find these questions confusing. As a result, they often either load way too many programs on their computer or don't load enough and later discover that their computer won't do what they want it to do.

    Fortunately for beginners, there's a much simpler way to install Linux.

    Specialized Linux Distributions

    A new subgroup of Linux distributions has started to appear. These are typically based on one of the main distributions but contain only a subset of applications that would make sense for a specific area of use.

    In addition to providing specialized software (such as only office products for business users), customized Linux distributions also attempt to help beginning Linux users by autodetecting and autoconfiguring common hardware devices. This makes installing Linux a much more enjoyable process.

    Table 1.6 shows some of the specialized Linux distributions available and what they specialize in.

    TABLE 1.6: Specialized Linux Distributions

    That's just a small sampling of specialized Linux distributions. There are hundreds of specialized Linux distributions, and more are popping up all the time on the Internet. No matter what your specialty, you'll probably find a Linux distribution made for you.

    Many of the specialized Linux distributions are based on the Debian Linux distribution. They use the same installation files as Debian but package only a small fraction of a full‐blown Debian system.

    THE LINUX LiveDVD

    Most Linux distributions also have a LiveDVD version available. The LiveDVD version is a self‐contained ISO image file that you can burn onto a DVD (or USB stick) to boot up a running Linux system directly, without having to install it on your hard drive. Depending on the distribution, the LiveDVD either contains a small subset of applications or, in the case of specialized distributions, the entire system. The benefit of the LiveDVD is that you can test it with your system hardware before going to the trouble of installing the system.

    The Bottom Line

    List the components of a standard Linux system. The main components of a Linux system include the Linux kernel, the GNU utilities, a user interface, and application programs. The kernel controls how memory, programs, and hardware all interact with one another. The GNU utilities provide useful functions such as text and file manipulation. The Linux user interfaces range from fancy graphical desktops, such as GNOME or KDE Plasma, to simple command‐line interfaces, such as the Bash Shell.

    Master It The Linux kernel is constantly updated and managed by a group of developers. They publish their work at the kernel.org website. Go to that website and determine the version number of the latest stable release. What version is currently under development?

    Explain how GNU utilities are used within Linux. The GNU utilities provide command‐line functions for creating, modifying, moving, and deleting files, as well as working with data inside text files. The main GNU utilities are in the coreutils package.

    Master It The GNU community is constantly making improvements to the core GNU utilities used in Linux. You can find the latest released utilities at www.gnu.org/software/coreutils/. Go to that website and determine the current version of the GNU coreutils package.

    Describe the various Linux user interface environments. There are many graphical desktop environments available in Linux. The two most popular ones are GNOME and KDE Plasma. Both provide common desktop features most desktop users are comfortable with. However, for server environments, it's most common to use a command‐line interface (CLI) provided by a Linux shell program. The most common Linux shell is bash.

    Master It The GNU Bash Shell is continually being updated, with updates available at www.gnu.org/software/bash/. According to that website, what is the most recent version of bash available for download?

    Explain why there are different Linux distributions. A Linux distribution bundles the various parts of a Linux system into a simple package that you can easily install on your PC. The Linux distribution world consists of full‐blown Linux distributions that include just about every application imaginable, as well as specialized Linux distributions that only include applications focused on a special function.

    Master It There are many websites that track Linux distributions. The www.distrowatch.com website is a popular place to get information on new releases for lots of different distributions. Go to that site and list the current top five Linux distribution downloads.

    Chapter 2

    Installing an Ubuntu Server

    Ubuntu Server is a popular Linux distribution, and most likely you will install it many times in your Linux career. Gaining experience with this distro's installation process will help you become a Linux expert.

    The first few times you install a particular operating system, it feels like a daunting task. And rightly so! Without proper guidance, the process can often result in frustration and lost time. Our goal in this chapter is to assist you through your first installation of the Ubuntu Server distribution. We provide step‐by‐step guidance, help you avoid pitfalls, and ultimately build your sysadmin skillset.

    IN THIS CHAPTER, YOU WILL LEARN TO

    Review needed Ubuntu Server hardware resources

    Determine the requirements for a virtual Ubuntu system

    Obtain Ubuntu Server software

    Conduct an installation of an Ubuntu Server

    Audit the Ubuntu Server's installation

    Pre‐Installation Requirements

    A graphical user interface (GUI) uses a lot of resources on a computer system, and if the server is not needed for providing a desktop to users, those applications and utilities are typically not installed. This is the case with the Ubuntu Server distribution. If you want a GUI on it, you'll have to add that software to it after the installation.

    The Ubuntu Server distribution is designed for a system that not only doesn't need a GUI, but is headless. Though that sounds like something in a horror movie, you often find these types of servers in modern server rooms. A headless system is simply a computer without a directly attached monitor. A sysadmin connects to the computer through the network to reach its text‐based command‐line interface.

    Before jumping into a Linux installation, it's wise to review what is needed to make the project successful. We're assuming that you already have your customer's requirements in hand and now need to determine what is required for an Ubuntu installation on a physical or virtualized server.

    UNDERSTANDING BASIC VIRTUALIZATION TERMS

    If you're unfamiliar with virtualization computer terms, it's a good idea to read through the first several pages of Chapter 22, Exploring the Virtualization Environment. But here are a few basic definitions to get you started:

    Virtual machine (VM)—A computer system that appears and acts as a physical computer server to its users and operating system but is actually a grouping of files and programs managed by a hypervisor

    Hypervisor—Software application used to create and manage virtual machines

    Host machine—The physical server on which the hypervisor and its virtual machines run

    In the next few sections, we'll look at the hardware requirements needed for installing the Ubuntu server distribution directly on a physical server and for installing it within a virtualized environment.

    Hardware Requirements

    If you plan on installing the Ubuntu Server 20.04LTS distribution directly on a headless server, your computer must support a 64‐bit processor architecture. Any of the following will work fine:

    AMD amd64

    ARM arm64

    IBM Z s390x

    Intel amd64

    LinuxONE s390x

    POWER8 or 9 ppc64el

    Besides having the proper processor on your system, you need to have enough resources available to avoid a sluggish system. Table 2.1 shows the recommended resources to support a well‐running Ubuntu Server distro.

    TABLE 2.1: Recommended Server Resources for Ubuntu Server Distribution

    Keep in mind that these recommendations are only for the operating system. Increase these resources to meet the needs of the application(s) you will run on the server.

    Not everyone has access to a physical server. But you can set up a virtual environment on a laptop or some old desktop you have stuffed away in your closet. Using a virtualized system on your daily laptop provides a great deal of flexibility. You can learn about Linux while sitting in the park!

    Virtual Server Requirements

    If you plan on running the Ubuntu Server distribution as a virtual machine, you need to ensure that the host machine's operating system is supported by the hypervisor.

    For this book, we're focusing on the Oracle VirtualBox hypervisor software. Here are a few

    Enjoying the preview?
    Page 1 of 1