Book Image

Linux Administration Cookbook

By : Adam K. Dean
Book Image

Linux Administration Cookbook

By: Adam K. Dean

Overview of this book

Linux is one of the most widely used operating systems among system administrators,and even modern application and server development is heavily reliant on the Linux platform. The Linux Administration Cookbook is your go-to guide to get started on your Linux journey. It will help you understand what that strange little server is doing in the corner of your office, what the mysterious virtual machine languishing in Azure is crunching through, what that circuit-board-like thing is doing under your office TV, and why the LEDs on it are blinking rapidly. This book will get you started with administering Linux, giving you the knowledge and tools you need to troubleshoot day-to-day problems, ranging from a Raspberry Pi to a server in Azure, while giving you a good understanding of the fundamentals of how GNU/Linux works. Through the course of the book, you’ll install and configure a system, while the author regales you with errors and anecdotes from his vast experience as a data center hardware engineer, systems administrator, and DevOps consultant. By the end of the book, you will have gained practical knowledge of Linux, which will serve as a bedrock for learning Linux administration and aid you in your Linux journey.
Table of Contents (15 chapters)

Understanding and choosing a distribution

Linux, as hinted at in the preceding section, is fragmented. There's no better way to describe this, due to the sheer number of different distributions you can download from a multitude of different vendors. Some of these vendors are for-profit, offering support contracts and SLAs with your purchase of their OS, and some are entirely voluntary, manned by one person in their garage.

There are literally hundreds of distributions to choose from, and each has their advocate-army to tell you why theirs is "the one true distribution" and "there's really no reason to go shopping around for a different one."

There are also Linux distributions that have been created for specific purposes, such as Red Star OS, the purportedly North Korean Linux distribution.

The truth of the matter is that most businesses use the Linux distribution they do because it was:

  • The first one that popped up when the owner Googled free OS
  • The one the first IT Administrator liked
  • The one that offers a contract they can invoke when something breaks

Going through each distribution that's around at the moment would be futile, as they're being created or abandoned on an almost weekly basis. Instead, I'm going to run through a popular selection (in the server space, rather than the desktop), explain some key differences, and then talk about which I'll be using for the rest of this book.

Don't be deterred if the distribution your business uses isn't one we talk about here most of the tooling is consistent across distributions, and where it differs, documentation exists to help you out.

If you want to learn more about the various distributions available to you, a site called DistroWatch (https://distrowatch.com/) has been around for years, and offers a regularly updated list of most Linux distributions, organized by page hit ranking.

Ubuntu

Ubuntu is the first Linux distribution I ever installed, and I'd wager the same could be said for a lot of people who started in Linux around the mid-2000s. It's also the distribution I'm using to write this book.

It has enjoyed consistent mindshare on the desktop, thanks to its decent attempt at marketing (including its position in Google's rankings when searching Linux), its perception as Linux for Human Beings, and its user-friendliness.

Downstream from Debian, Ubuntu's development is headed by Canonical, and while they started with an emphasis on making a rock-solid desktop OS, they have since moved into the lofty realms of attempting to dominate the server space, and have entered the IoT device market too.

When we say "downstream" in this sense, we mean that Ubuntu shares a lot of its foundation with Debian, except it adds some extra bits and takes some bits out. In the Linux world, there are few from-scratch distributions, with most using another distribution as their bedrock.

Known also for its cutesy naming convention (18.04 being Bionic Beaver), the fact Ubuntu was so popular on the desktop meant it was the obvious distribution of choice for sysadmins to install on their servers, reaching for what they were already familiar with.

More recently, it's become increasingly common to find Ubuntu installations when dealing with inherited systems, usually a long-term support (LTS) release (so that confusion and headaches around OS upgrades can be avoided for a reasonable length of time.)

Ubuntu releases on a six-monthly cycle, with every two years being an LTS release (14.04, 16.04, and 18.04, most recently). Their numbering convention is year-released, followed by month (so April 2018 is 18.04). It is possible to upgrade from version to version of Ubuntu.

Canonical also aren't shy of introducing new technology and software in Ubuntu, even when it diverges from their Debian base. Recent examples of this include the following:

  • Snaps: A way of distributing distribution-agnostic software
  • Upstart: A replacement initialization system that was later also replaced by systemd
  • Mir: A display server, which was initially conceived as a way to replace the ageing X Window System
Ubuntu can be downloaded from https://ubuntu.com.

Debian

As mentioned previously, Debian (the universal OS) is the basis for a lot of other distributions that came later, but it has consistently been one of the most popular, both on the desktop and on servers. It is still highly likely that you will choose to install Debian yourself, or will inherit a system running this distribution, with its reputation for stability.

Traditionally, the server-space war was fought between two camps, the Debian Druids and the CentOS Cardinals. In more recent years, newcomers have entered the fray (like Ubuntu,) but these two still hold a considerable amount of hardware to ransom.

Releasing every two or three years, the Debian versions are named after Toy Story characters (7—Wheezy, 8Jessie, 9Stretch). They have a reputation for being one of the most stable Linux distributions around, with tried and tested versions of software, as well as sensibly backported fixes.

Backporting is the act of taking a fix from a recent release of software, such as the kernel itself, and incorporating those fixes into the version you're running, recompiling it into a new piece of software. Features are rarely backported, due to features having the potential to introduce more breaking changes into long-term support distributions.

Some criticism is sometimes leveled at Debian because it generally has older versions of packages available in its release version, which may not include all the trendy and cool features a systems administrator wants, or a developer desires. This isn't fair, given that people generally look for stability and security in the server world, over the latest and greatest version of Node.js.

Debian has staunch defenders, and it holds a special place in a lot of hearts, though it's unusual to see it in some Enterprise environments because it's developed by the Debian Project, rather than a traditional company that can offer support contracts. In my anecdotally dismissible experience, I have more often seen Debian in smaller companies who needed a quick solution, and slightly larger companies who still run some legacy systems.

Debian can be downloaded from https://www.debian.org.

CentOS - the one we'll mostly be using

The other part of the traditional server-space war, CentOS features its own soldiers and martyrs. It is still widely used, and has a reputation for stability and boredom that rivals Debian's.

The Community Enterprise Operating System (CentOS) is a freely available and compiled version of the Red Hat Enterprise Linux distribution, which aims to offer functional compatibility, generally replacing the Red Hat logo with the CentOS logo to avoid trademark infringement. (In January of 2014 it was announced that Red Hat was joining forces with CentOS, to help drive and invest in CentOS development.)

Because of its nature, a lot of systems administrators have installed CentOS to better understand the Red Hat world, because (as mentioned previously) Red Hat has a good reputation in Enterprise companies, so it would make sense to install something so strikingly similar.

This installation trend goes both ways. I have seen companies who started out by installing CentOS because it was readily available and allowed them to design their infrastructure easily, utilizing publicly available and free repos, before moving to a RHEL deployment for the finished product.

Repos is a short form way of saying repositories, which are the common location from which software is installed on a Linux system. Where Windows usually has downloads from websites, and macOS has the App Store, Linux has used software repositories for most of its life, and they have the advantage of being easily searchable with a few keystrokes on the command line.

I have also seen companies who deployed RHEL everywhere, only to realise that they were spending a lot of money, and never invoking the support they'd bought because their operations team was just that good! They would then gradually phase out their Red Hat deployments and move to CentOS, changing very little in the process.

Releases come about every few years, with version 7 being released in 2014, and getting consistent updates since then. However, it should be noted that version 6, which was released in 2011, will be getting maintenance updates until 2020.

CentOS can be downloaded from https://centos.org. We will go through this in the installation section.

Red Hat Enterprise Linux

Red Hat Enterprise Linux, or RHEL as it's more commonly known (because it's a long name), has a very firm footing in Enterprises. It targets the commercial space very well, and as a result it is not uncommon to find yourself on a RHEL box, which you've initially assumed to be a CentOS installation.

What makes RHEL different is the support offered by Red Hat, Inc. and the various services that you can utilize if you've bought an official package.

While Red Hat still offers the source code for their distribution without question (hence CentOS), they sell versions and packages for everything from the desktop up to data centre installations.

There's an adage that states "no one got fired for buying IBM," which is a little dated in this day and age, but I've heard people invoke this philosophy to describe Red Hat on more than one occasion. No one will get fired for buying Red Hat (but you might be asked what the benefits are of paying for something that's available for free under another name.)

Beautifully, it was announced while I was in the editing stage of this book that IBM have bought Red Hat, bringing my comment above full circle. The universe is great sometimes.

Aside from the support, the business-like attitude that other businesses like, and the contributions back to the community as a whole, Red Hat also offer something which has been variously described as "a waste of time" and "crucial for this role."

Exams are looked at with both affection and derision, depending on who you speak to in the Linux community (as with many things, there's something of a holy war about them). Red Hat offers two of the most popular, and many more to boot. You can study for and become a Red Hat Certified System Administrator, followed by a Red Hat Certified Engineer, which are widely seen as very acceptable qualifications to have.

As a college dropout, I'm quite happy to have an RHCE qualification under my belt.

Some people see these exams as a way of getting past the first line of those hiring (as in the people who scan your CV, and look for badges they recognize). Others see them as proof that you know what you're doing around a Linux system due to the fact that these exams are practical, (meaning they sit you in front of a computer and give you a set of steps to finish.) Some people dismiss exams altogether, although they're usually the ones who've never bothered trying the exam.

Take a look at https://www.redhat.com, taking particular note of the various packages on offer. They do have a developer account too, which gives you access to services you would otherwise pay for (as long as you don't try and sneak them into a production environment!).