Linux Service Management Made Easy with systemd
eBook - ePub

Linux Service Management Made Easy with systemd

Donald A. Tevault

Share book
  1. 420 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Linux Service Management Made Easy with systemd

Donald A. Tevault

Book details
Book preview
Table of contents
Citations

About This Book

A comprehensive guide for teaching system administrators, developers, and security professionals how to create their own systemd units and maintain system security

Key Features

  • Maintain and troubleshoot systemd services with ease
  • Learn to create, modify, and reload service files and use systemd utilities
  • Use cgroups to control resource usage and enhance security

Book Description

Linux Service Management Made Easy with systemd will provide you with an in-depth understanding of systemd, so that you can set up your servers securely and efficiently.This is a comprehensive guide for Linux administrators that will help you get the best of systemd, starting with an explanation of the fundamentals of systemd management.You'll also learn how to edit and create your own systemd units, which will be particularly helpful if you need to create custom services or timers and add features or security to an existing service.Next, you'll find out how to analyze and fix boot-up challenges and set system parameters. An overview of cgroups that'll help you control system resource usage for both processes and users will also be covered, alongside a practical demonstration on how cgroups are structured, spotting the differences between cgroups Version 1 and 2, and how to set resource limits on both.Finally, you'll learn about the systemd way of performing time-keeping, networking, logging, and login management. You'll discover how to configure servers accurately and gather system information to analyze system security and performance.By the end of this Linux book, you'll be able to efficiently manage all aspects of a server running the systemd init system.

What you will learn

  • Use basic systemd utilities to manage a system
  • Create and edit your own systemd units
  • Create services for Podman-Docker containers
  • Enhance system security by adding security-related parameters
  • Find important information with journald
  • Analyze boot-up problems
  • Configure system settings with systemd utilities

Who this book is for

This book is best suited for Linux administrators who want to learn more about maintaining and troubleshooting Linux servers. It will also be useful for aspiring administrators studying for a Linux certification exam, developers looking to learn how to create systemd unit files, and security administrators who want to understand the security settings that can be used in systemd units and how to control resource usage with cgroups. Before you dive into this book, you'll need a solid working knowledge of basic Linux commands.

]]>

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Linux Service Management Made Easy with systemd an online PDF/ePUB?
Yes, you can access Linux Service Management Made Easy with systemd by Donald A. Tevault in PDF and/or ePUB format, as well as other popular books in Informatique & Administration du système. We have over one million books available in our catalogue for you to explore.

Information

Year
2022
ISBN
9781801815031

Section 1: Using systemd

Upon completion of Part 1, you will know how to control system services, set environment parameters, and create new systemd units.
This part of the book comprises the following chapters:
  • Chapter 1, Understanding the Need for systemd
  • Chapter 2, Understanding systemd Directories and Files
  • Chapter 3, Understanding Service, Path, and Socket Units
  • Chapter 4, Controlling systemd Services
  • Chapter 5, Creating and Editing Services
  • Chapter 6, Understanding systemd Targets
  • Chapter 7, Understanding systemd Timers
  • Chapter 8, Understanding the systemd Boot Process
  • Chapter 9, Setting System Parameters
  • Chapter 10, Understanding Shutdown and Reboot Commands

Chapter 1: Understanding the Need for systemd

In this first chapter, we'll first briefly look at the history of Linux init systems. We'll then look at the shortcomings of the legacy init systems and why certain Linux engineers felt the need to develop a new type of init system. Finally, we'll look at the controversy that has surrounded systemd. For easy reference, here's a list of the topics:
  • The history of Linux init systems
  • The shortcomings of SysV init and upstart
  • The advantages of systemd
  • The systemd controversy
So, with the introductory comments out of the way, let's jump in.

Technical requirements

For this chapter, all you need is a Linux virtual machine that runs systemd. As you read through this chapter, you might want to look at some of the files on the virtual machine.

The history of Linux init systems

So, what is an init system? Well, init is short for initialization. An init system, then, initializes the operating system upon bootup. After the bootup has completed, the init system will continue working, managing system processes and services. Each system process is assigned a process ID number, or PID. The init process is always PID 1, and every other process that gets started on the system is either a child or a grandchild of the init process.
For many years, the SysV Init system was the primary init system for Linux-based operating systems (SysV is short for System 5. The V is the Roman numeral for 5). SysV init was originally developed by Bell Labs engineers for the Unix operating system, all the way back in the early 1970s. (At that time, I was a young pup in junior high school, and I still had a full head of hair.)
Note
There are actually a few more Linux init systems besides the ones that I'm mentioning here. But these were the most commonly used ones in the pre-systemd days.
SysV init worked well in its day, but it was never perfect. Nowadays, with new high-performance hardware, SysV init has shown both its age and its deficiencies. The first attempt to come up with something better occurred in July 2009, when Ubuntu engineers released the first version of the upstart init system. Although it was better than SysV, it still had its share of problems, especially the early versions which were quite buggy.

The shortcomings of SysV Init and upstart

The first problem with SysV is that of its rather lengthy boot-up times. When you boot up a SysV machine, all of its services have to start up in sequential order. That might not be so bad on a normal desktop machine, but it can be a bit problematic on a server that needs to run lots of services. In that case, each service would have to wait its turn to start, which could take a while.
The next problem with SysV is its complexity. Instead of simple, easy-to-understand configuration files, SysV does everything with complex Bash shell scripts. The init scripts that control system services all have to be assigned a priority number, so that services will start and stop in the proper order. Take, for example, the init script that starts the Apache web server on a CentOS 5 machine. First, we can see that it's a fairly lengthy script, as shown here:
[student@localhost init.d]$ pwd
/etc/init.d
[student@localhost init.d]$ ls -l httpd
-rwxr-xr-x 1 root root 3523 Sep 16 2014 httpd
[student@localhost init.d]$ wc -l httpd
131 httpd
[student@localhost init.d]$
You can see from the wc -l output that it consists of 131 lines. As you can see here, 37 of those lines are comments, which still leaves us with 94 lines of actual code:
[student@localhost init.d]$ grep ^# httpd | wc -l
37
[student@localhost init.d]$
Look inside, and you'll see that it's quite complex and convoluted. Here's just the first part of it:
Figure 1.1 – An old-fashioned SysV Init script
Toward the end of the script, you'll see the code that stops, starts, restarts, and reloads the Apache daemon, as shown here:
Figure 1.2 – The start, stop, r...

Table of contents