
Linux Service Management Made Easy with systemd: Advanced techniques to effectively manage, control, and monitor Linux systems and services
- Length: 420 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-02-03
- ISBN-10: 1801811644
- ISBN-13: 9781801811644
- Sales Rank: #1725253 (See Top 100 Books)
A comprehensive guide for teaching system administrators, developers, and security professionals how to create their own systemd units and maintain system security
Key Features
- Get well-versed with maintaining and troubleshooting systemd services
- Learn to create, modify, and reload service files and use systemd utilities
- Use cgroups to control resource usage and enhance security
Book Description
systemd is a new type of Linux init system for today’s high-performance, multi-CPU, and multi-core hardware that is now used on all major enterprise-grade Linux distros. The main goal of this Linux systemd book is to help you get an in-depth understanding of systemd to set up your servers securely and efficiently.
This book starts by explaining systemd management, which will help you manage your servers effectively. You’ll then 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 understand how to analyze and fix boot-up challenges and set system parameters. Later, you’ll come across cgroups, that’ll help you control system resource usage for both processes and users. The book also shows you how cgroups are structured, 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 for Linux administrators who want to learn more about maintaining and troubleshooting Linux servers. Aspiring administrators studying for a Linux certification exam and developers looking to learn how to create systemd unit files will also find this book useful. Additionally, this book will be helpful for security administrators who want to understand the security settings that can be used in systemd units and how to control resource usage with cgroups. Working knowledge of basic Linux commands is assumed.
Table of Contents
- Understanding the Need for systemd
- Understanding systemd Directories and Files
- Understanding Service, Path, and Socket Units
- Controlling systemd Services
- Creating and Editing Services
- Understanding systemd Targets
- Understanding systemd Timers
- Understanding the systemd Boot Process
- Setting System Parameters
- Understanding Shutdown and Reboot Commands
- Understanding cgroups Version 1
- Controlling Resource Usage with cgroups Version 1
- Understanding cgroup Version 2
- Using journald
- Using systemd-networkd and systemd-resolved
- Understanding Timekeeping with systemd
- Understanding systemd and Bootloaders
- Understanding systemd-logind
Linux Service Management Made Easy with systemd Contributors About the author About the reviewer Preface Who this book is for What this book covers To get the most out of this book Download the example code files Code in Action Download the color images Conventions used Get in touch Share Your Thoughts Section 1: Using systemd Chapter 1: Understanding the Need for systemd Technical requirements The history of Linux init systems The shortcomings of SysV Init and upstart The advantages of systemd systemd's simplicity systemd's consistency systemd's performance systemd security The systemd controversy Summary Questions Answers Further reading Chapter 2: Understanding systemd Directories and Files Technical requirements Understanding the systemd configuration files Understanding the systemd unit files Types of unit files Understanding the systemd executables Summary Questions Answers Further reading Chapter 3: Understanding Service, Path, and Socket Units Technical requirements Understanding service units Understanding the Apache service file Understanding the Secure Shell service file Understanding the timesyncd service file Understanding socket units Understanding path units Summary Questions Answers Further reading Chapter 4: Controlling systemd Services Technical requirements Verifying the status of a service Starting, stopping, and reloading services Enabling and disabling services Killing a service Masking a service Summary Questions Answers Further reading Chapter 5: Creating and Editing Services Technical requirements Editing an existing service Creating a partial edit to the [Install] section Creating a partial edit to the [Service] section Creating a full edit Creating a new service Changing the default systemd editor Creating a new container service with podman Summary Questions Answers Further reading Chapter 6: Understanding systemd Targets Technical requirements Understanding the purpose of systemd targets Understanding the structure of a target file Understanding the sockets.target file Understanding dependencies in the sshd.service file Comparing systemd targets to SysVinit runlevels Understanding target dependencies Changing the default target Temporarily changing the target Summary Questions Answers Further reading Chapter 7: Understanding systemd Timers Technical requirements Comparing systemd timers with cron Viewing timer information Understanding timer options Understanding monotonic timers Understanding real-time timers Understanding calendar events for real-time timers Creating timers Creating a system-level timer Creating a user-level timer Summary Questions Answers Further reading Chapter 8: Understanding the systemd Boot Process Technical requirements Comparing SysV bootup and systemd bootup Understanding SysV and systemd bootup similarities Understanding the SysV bootup process Understanding the systemd bootup process Analyzing bootup performance Some differences on Ubuntu Server 20.04 Understanding systemd generators Understanding mount units Understanding backward compatibility Summary Questions Answers Further reading Chapter 9: Setting System Parameters Technical requirements Setting the locale parameter Understanding the locale Changing the default locale on the Alma machine Changing the default locale on Ubuntu Setting time and timezone parameters Setting the hostname and machine information Viewing the information Setting the information Summary Questions Answers Further reading Chapter 10: Understanding Shutdown and Reboot Commands Technical requirements Shutting down with systemctl Halting with systemctl Rebooting with systemctl Using shutdown instead of systemctl Running a job before shutting down Summary Questions Answers Further reading Section 2: Understanding cgroups Chapter 11: Understanding cgroups Version 1 Technical requirements Understanding the history of cgroups Understanding the purpose of cgroups Understanding the structure of cgroups Version 1 Understanding the cgroup filesystem Summary Questions Answers Further reading Chapter 12: Controlling Resource Usage with cgroups Version 1 Technical requirements Understanding resource controllers Examining the resource controllers Preparing for the demos Controlling CPU usage Controlling Vicky's CPU usage Controlling CPU usage for a service Controlling memory usage Controlling blkio usage Setting a blkio limit for Vicky Setting a blkio limit for a service Understanding pam_limits and ulimit The ulimit command The pam_limits module Summary Questions Answers Further reading Chapter 13: Understanding cgroup Version 2 Technical requirements Understanding the need for Version 2 Version 1 complexity Version 1 attribute filenames No support for rootless containers Understanding the improvements in cgroup Version 2 Setting resource limits on rootless containers Understanding cpuset Converting RHEL 8-type distros to cgroup version 2 Summary Questions Answers Further reading Section 3: Logging, Timekeeping, Networking, and Booting Chapter 14: Using journald Technical requirements Understanding the pros and cons of rsyslog Understanding the pros and cons of journald Understanding journald on Ubuntu Understanding journald on RHEL-type systems Using journalctl Searching for and viewing log data with journalctl Sealing journald log files for security Setting up remote logging with journald Summary Questions Answers Further reading Chapter 15: Using systemd-networkd and systemd-resolved Technical requirements Understanding networkd and resolved Understanding Netplan on Ubuntu Viewing installer-generated Netplan configurations Creating Netplan configurations Understanding networkd and resolved on RHEL-type machines Using networkctl and resolvectl Viewing the networkd and resolved unit files Summary Questions Answers Further reading Chapter 16: Understanding Timekeeping with systemd Technical requirements Understanding the importance of accurate time Comparing NTP implementations Understanding chrony on the AlmaLinux machine The chronyd.service file The chrony.conf file Setting up a chronyd time server Using chronyc Understanding systemd-timesyncd The systemd-timesyncd.service file The timesyncd.conf file Using timedatectl Configuring Ubuntu to use chrony Understanding the Precision Time Protocol An overview of PTP Installing PTP Configuring PTP with software timestamping on AlmaLinux Configuring PTP with hardware timestamping on AlmaLinux Configuring PTP with software timestamping on Ubuntu Configuring PTP with hardware timestamping on Ubuntu Summary Questions Answers Further reading Chapter 17: Understanding systemd and Bootloaders Technical requirements Understanding the basic computer architecture Understanding GRUB2 Comparing GRUB2 on BIOS and EFI/UEFI systems GRUB2 on BIOS-based and EFI/UEFI-based Ubuntu machines Understanding systemd-boot Understanding Secure Boot Summary Questions Answers Further reading Chapter 18: Understanding systemd-logind Technical requirements Understanding the need for a new login service Understanding systemd-logind.service The Alma Linux systemd-logind.service file The Ubuntu Server systemd-logind.service file Understanding logind.conf Virtual terminals Keeping user processes going after logout Power management directives The IdleAction directives Understanding loginctl Understanding polkit Summary Questions Answers Further reading Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Linux Service Management Made Easy with systemd: Advanced techniques to effectively manage, control, and monitor Linux systems and services
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.