Linux Service Management Made Easy with systemd
eBook - ePub

Linux Service Management Made Easy with systemd

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

Linux Service Management Made Easy with systemd

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

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
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.
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.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
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 Computer Science & Software Development. We have over one million books available in our catalogue for you to explore.

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

  1. Linux Service Management Made Easy with systemd
  2. Contributors
  3. Preface
  4. Section 1: Using systemd
  5. Chapter 1: Understanding the Need for systemd
  6. Chapter 2: Understanding systemd Directories and Files
  7. Chapter 3: Understanding Service, Path, and Socket Units
  8. Chapter 4: Controlling systemd Services
  9. Chapter 5: Creating and Editing Services
  10. Chapter 6: Understanding systemd Targets
  11. Chapter 7: Understanding systemd Timers
  12. Chapter 8: Understanding the systemd Boot Process
  13. Chapter 9: Setting System Parameters
  14. Chapter 10: Understanding Shutdown and Reboot Commands
  15. Section 2: Understanding cgroups
  16. Chapter 11: Understanding cgroups Version 1
  17. Chapter 12: Controlling Resource Usage with cgroups Version 1
  18. Chapter 13: Understanding cgroup Version 2
  19. Section 3: Logging, Timekeeping, Networking, and Booting
  20. Chapter 14: Using journald
  21. Chapter 15: Using systemd-networkd and systemd-resolved
  22. Chapter 16: Understanding Timekeeping with systemd
  23. Chapter 17: Understanding systemd and Bootloaders
  24. Chapter 18: Understanding systemd-logind
  25. Other Books You May Enjoy