Mastering Ubuntu Server: Explore the versatile, powerful Linux Server distribution Ubuntu 22.04 with this comprehensive guide, 4th Edition / Осваиваем Ubuntu Server: Познакомьтесь с универсальным и мощным серверным дистрибутивом Linux Ubuntu 22.04 с помощью этого подробного руководства, 4-е издание Год издания: 2022 Автор: LaCroix Jay / Лакруа Джей Издательство: Packt Publishing ISBN: 978-1-80323-424-3 Серия: Expert Insight Язык: Английский Формат: PDF/EPUB/MOBI Качество: Издательский макет или текст (eBook) Интерактивное оглавление: Да Количество страниц: 583 Описание: Your one-stop resource to learn, configure and use Ubuntu 22.04 for your day-to-day operations and deployments. Key Features Get well-versed with newly added features in Ubuntu 22.04 Master the art of installing, managing, and troubleshooting Ubuntu Server Leverage the improved performance and security-related aspects of Ubuntu Server 22.04 Book Description Ubuntu Server is taking the server world by storm - and for a good reason! The server-focused spin of Ubuntu is a stable, flexible, and powerful enterprise-class distribution of Linux with a focus on running servers both small and large. Mastering Ubuntu Server is a book that will teach you everything you need to know in order to manage real Ubuntu-based servers in actual production deployments. This book will take you from initial installation to deploying production-ready solutions to empower your small office network, or even a full data center. You'll see examples of running an Ubuntu Server in the cloud, be walked through set up popular applications (such as Nextcloud), host your own websites, and deploy network resources such as DHCP, DNS, and others. You’ll also see how to containerize applications via LXD to maximize efficiency and learn how to build Kubernetes clusters. This new fourth edition updates the popular book to cover Ubuntu 22.04 LTS, which takes advantage of the latest in Linux-based technologies. By the end of this Ubuntu book, you will have gained all the knowledge you need in order to work on real-life Ubuntu Server deployments and become an expert Ubuntu Server administrator who is well versed in its feature set. What you will learn Install Ubuntu Server on physical servers and on the Raspberry Pi Deploy Ubuntu Server in the cloud and host websites on your own server Deploy your applications to their own containers and scale your infrastructure Set up popular applications such as Nextcloud Automate deployments and configuration with Ansible to save time Containerize applications via LXD to maximize efficiency Discover best practices and troubleshooting techniques Who this book is for This book is for System Administrators, Site Reliability Engineers, DevOps professionals, enthusiasts, as well as for individuals looking to make a career change and learn the skills they'll need to work with Ubuntu servers. Prior knowledge of Ubuntu is not required but a basic understanding of basic computing concepts is assumed. Some IT administration, Linux, and shell scripting experience is preferred, although the first several chapters will bring newcomers up to speed as well. Ваш универсальный ресурс для изучения, настройки и использования Ubuntu 22.04 в повседневной работе и развертывании. Ключевые функции Познакомьтесь с новыми функциями Ubuntu 22.04 Освоите технику установки, управления и устранения неполадок на сервере Ubuntu Server Используйте улучшенные возможности Ubuntu Server 22.04, связанные с производительностью и безопасностью Описание книги Ubuntu Server стремительно завоевывает мир серверов - и не без оснований! Серверная составляющая Ubuntu - это стабильный, гибкий и мощный дистрибутив Linux корпоративного класса, ориентированный на работу как с маленькими, так и с большими серверами. "Освоение Ubuntu Server" - это книга, которая научит вас всему, что вам нужно знать для управления реальными серверами на базе Ubuntu в реальных производственных условиях. В этой книге вы пройдете путь от начальной установки до развертывания готовых к работе решений для расширения возможностей вашей небольшой офисной сети или даже полноценного центра обработки данных. Вы увидите примеры запуска сервера Ubuntu в облаке, узнаете о настройке популярных приложений (таких как Nextcloud), размещении собственных веб-сайтов и развертывании сетевых ресурсов, таких как DHCP, DNS и другие. Вы также узнаете, как контейнеризировать приложения с помощью LXD для достижения максимальной эффективности, и научитесь создавать кластеры Kubernetes. В этом новом, четвертом издании популярной книги рассказывается об Ubuntu 22.04 LTS, в которой используются новейшие технологии на базе Linux. К концу прочтения этой книги по Ubuntu вы получите все знания, необходимые для работы с реальными установками Ubuntu Server, и станете опытным администратором Ubuntu Server, который хорошо разбирается в наборе функций Ubuntu Server. Чему вы научитесь Установите Ubuntu Server на физические серверы и на Raspberry Pi Развертывайте сервер Ubuntu в облаке и размещайте веб-сайты на своем собственном сервере Размещайте свои приложения в собственных контейнерах и масштабируйте инфраструктуру Настраивайте популярные приложения, такие как Nextcloud Автоматизируйте развертывание и настройку с помощью Ansible для экономии времени Контейнеризируйте приложения с помощью LXD для максимальной эффективности Ознакомьтесь с рекомендациями и методами устранения неполадок Для кого предназначена эта книга Эта книга предназначена для системных администраторов, инженеров по обеспечению надежности сайтов, специалистов DevOps, энтузиастов, а также для тех, кто хочет сменить профессию и приобрести навыки, необходимые для работы с серверами Ubuntu. Предварительное знание Ubuntu не требуется, но предполагается базовое понимание основных компьютерных концепций. Желательно иметь некоторый опыт ИТ-администрирования, работы с Linux и shell-скриптами, хотя первые несколько глав также введут в курс дела новичков.
Примеры страниц (скриншоты)
Оглавление
Preface xi Chapter 1: Deploying Ubuntu Server 1 Technical requirements ............................................................................................................ 2 Determining your server’s role .................................................................................................. 2 Choosing a device for our server ............................................................................................... 3 Physical server • 3 Physical desktop • 4 Laptop • 4 Virtual machine • 5 Virtual private server • 5 Raspberry Pi • 5 Obtaining installation media .................................................................................................... 6 Creating a bootable flash drive .................................................................................................. 8 Planning the partitioning layout • 11 Installing Ubuntu Server ........................................................................................................ 12 Installing Ubuntu on a Raspberry Pi ....................................................................................... 25 Summary ............................................................................................................................... 28 Relevant tutorials ................................................................................................................... 29 Chapter 2: Managing Users and Permissions 31 Understanding the purpose of users and groups ...................................................................... 32 Understanding when to use root ............................................................................................. 32 Using sudo to run privileged commands • 33 Creating and removing users .................................................................................................. 34 Using useradd • 34 Using adduser • 36 Removing users • 37 Understanding the /etc/passwd and /etc/shadow files .............................................................. 39 Understanding the /etc/passwd file • 39 Understanding the /etc/shadow file • 41 Distributing default configuration files with /etc/skel ............................................................... 43 Switching users ...................................................................................................................... 45 Managing groups ................................................................................................................... 46 Managing passwords and password policies ............................................................................ 49 Locking and unlocking user accounts • 49 Setting password expiration information • 50 Setting a password policy • 51 Configuring administrator access with sudo ............................................................................ 53 Setting permissions on files and directories ............................................................................ 56 Viewing permissions • 56 Changing permissions • 59 Changing the ownership of objects • 60 Summary ............................................................................................................................... 61 Relevant videos ...................................................................................................................... 61 Further reading ...................................................................................................................... 62 Chapter 3: Managing Software Packages 63 Understanding Linux package management ............................................................................ 63 Understanding the differences between Debian and Snap packages ......................................... 65 Debian packages • 65 Snap packages • 66 Installing and removing software ............................................................................................ 68 Managing Debian packages with apt • 68 Managing Snap packages with snap • 71 Searching for packages ........................................................................................................... 73 Managing package repositories ............................................................................................... 75 Adding additional repositories • 75 Adding Personal Package Archives • 77 Backing up and restoring Debian packages .............................................................................. 78 Cleaning up orphaned apt packages ........................................................................................ 79 Taking advantage of hardware enablement updates ................................................................. 81 Summary ............................................................................................................................... 83 Relevant video ........................................................................................................................ 83 Further reading ...................................................................................................................... 83 Chapter 4: Navigating and Essential Commands 85 Learning essential Linux commands ....................................................................................... 85 Understanding the Linux filesystem layout .............................................................................. 89 Viewing the contents of files ................................................................................................... 91 Viewing application log files ................................................................................................... 94 Summary ............................................................................................................................... 95 Relevant video ........................................................................................................................ 95 Further reading ...................................................................................................................... 95 Chapter 5: Managing Files and Directories 97 Copying, moving, and renaming files and directories .............................................................. 97 Editing files with the Nano and Vim text editors ....................................................................... 99 Editing with Nano • 100 Editing with Vim • 102 Input and output streams ..................................................................................................... 108 Using symbolic and hard links .............................................................................................. 111 Summary ............................................................................................................................. 113 Relevant videos .................................................................................................................... 113 Chapter 6: Boosting Your Command-line Efficiency 115 Understanding the Linux shell .............................................................................................. 115 Understanding Bash history ................................................................................................. 117 Learning some useful command-line tricks ........................................................................... 119 Understanding variables ....................................................................................................... 122 Writing simple scripts .......................................................................................................... 124 Putting it all together – Writing an rsync backup script .......................................................... 129 Summary ............................................................................................................................. 131 Relevant videos .................................................................................................................... 131 Further reading .................................................................................................................... 131 Chapter 7: Controlling and Managing Processes 133 Managing jobs ...................................................................................................................... 133 Understanding the ps command ........................................................................................... 136 Viewing running processes with ps • 136 Configuring arguments to ps • 137 Changing the priority of processes ........................................................................................ 141 Dealing with misbehaving processes ..................................................................................... 145 Managing system processes .................................................................................................. 148 Scheduling tasks with cron ................................................................................................... 151 Summary ............................................................................................................................. 153 Relevant videos .................................................................................................................... 154 Further reading .................................................................................................................... 154 Chapter 8: Monitoring System Resources 155 Viewing disk usage ............................................................................................................... 155 Using df • 156 Diving deeper into disk usage • 158 Monitoring memory usage .................................................................................................... 161 Understanding server memory • 161 Managing swap • 163 Understanding load average ................................................................................................. 166 Viewing resource usage with htop ......................................................................................... 168 Summary ............................................................................................................................. 172 Relevant videos .................................................................................................................... 172 Further reading .................................................................................................................... 172 Chapter 9: Managing Storage Volumes 173 Adding additional storage volumes ........................................................................................ 173 Formatting and partitioning storage devices .......................................................................... 176 Creating a partition • 177 Formatting partitions • 180 Mounting and unmounting volumes ...................................................................................... 182 Understanding the /etc/fstab file ........................................................................................... 184 Analyzing the contents of /etc/fstab • 184 Adding to the /etc/fstab file • 186 Backing up and restoring volumes ........................................................................................ 188 Utilizing LVM ....................................................................................................................... 190 Getting started with LVM • 191 Formatting logical volumes • 195 Removing volumes with LVM • 197 Understanding LVM snapshots • 198 Summary ............................................................................................................................. 199 Relevant videos .................................................................................................................... 200 Further reading .................................................................................................................... 200 Chapter 10: Connecting to Networks 201 Setting the hostname ............................................................................................................ 201 Managing network interfaces ............................................................................................... 204 Assigning static IP addresses ................................................................................................ 209 Understanding Linux name resolution .................................................................................. 213 Getting started with OpenSSH ............................................................................................... 215 Installing OpenSSH • 216 Issuing commands with OpenSSH • 217 Getting started with SSH key management ............................................................................ 219 Generating public and private keys • 220 Copying your public key to a remote server • 221 Utilizing an SSH agent • 222 Changing the passphrase of an OpenSSH key • 223 Simplifying SSH connections with a config file ...................................................................... 223 Summary ............................................................................................................................. 225 Relevant videos .................................................................................................................... 225 Further reading .................................................................................................................... 225 Chapter 11: Setting Up Network Services 227 Planning your IP address scheme .......................................................................................... 227 Setting up a DHCP server for serving IP addresses ................................................................. 231 Adding a DNS server ............................................................................................................. 236 Setting up external DNS with bind • 237 Setting up internal DNS and adding hosts • 239 Setting up an internet gateway .............................................................................................. 243 Summary ............................................................................................................................. 245 Further reading .................................................................................................................... 245 Chapter 12: Sharing and Transferring Files 247 File server considerations ..................................................................................................... 247 Sharing files with Windows users via Samba .......................................................................... 249 Setting up NFS shares ........................................................................................................... 254 Transferring files with rsync ................................................................................................. 258 Transferring files with SCP ................................................................................................... 261 Summary ............................................................................................................................. 263 Relevant videos .................................................................................................................... 263 Further reading .................................................................................................................... 263 Chapter 13: Managing Databases 265 Preparations for setting up a database server ........................................................................ 265 Installing MariaDB ............................................................................................................... 267 Understanding the MariaDB configuration files ..................................................................... 269 Managing MariaDB databases ............................................................................................... 272 Setting up a secondary database server ................................................................................. 278 Summary ............................................................................................................................. 283 Further reading .................................................................................................................... 283 Chapter 14: Serving Web Content 285 Installing and configuring Apache ........................................................................................ 285 Installing additional Apache modules ................................................................................... 291 Securing Apache with TLS .................................................................................................... 293 Installing and configuring NGINX ......................................................................................... 299 Setting up and configuring Nextcloud ................................................................................... 303 Summary ............................................................................................................................. 310 Relevant videos .................................................................................................................... 310 Further reading .................................................................................................................... 310 Chapter 15: Automating Server Configuration with Ansible 313 Understanding the need for configuration management ........................................................ 313 Why Ansible? ....................................................................................................................... 315 Creating a Git repository ....................................................................................................... 316 Getting started with Ansible ................................................................................................. 319 Making your servers do your bidding .................................................................................... 321 Setting up an inventory file and configuring Ansible settings • 321 Configuring client servers • 323 Putting it all together – automating web server deployment ................................................... 327 Using Ansible’s pull method .................................................................................................. 330 Summary ............................................................................................................................. 334 Relevant videos .................................................................................................................... 334 Further reading .................................................................................................................... 334 Chapter 16: Virtualization 337 Prerequisites and considerations .......................................................................................... 337 Setting up a virtual machine server ....................................................................................... 339 Creating virtual machines .................................................................................................... 345 Bridging the virtual machine network ................................................................................... 351 Simplifying virtual machine creation with cloning ................................................................ 354 Managing virtual machines via the command line ................................................................. 356 Summary ............................................................................................................................. 357 Relevant video ...................................................................................................................... 357 Further reading .................................................................................................................... 357 Chapter 17: Running Containers 359 What is containerization? ..................................................................................................... 359 Understanding the differences between Docker and LXD ....................................................... 361 Installing Docker .................................................................................................................. 362 Managing Docker containers ................................................................................................ 363 Automating Docker image creation with Dockerfiles .............................................................. 371 Managing LXD containers ..................................................................................................... 373 Summary ............................................................................................................................. 377 Relevant videos .................................................................................................................... 377 Further reading .................................................................................................................... 377 Chapter 18: Container Orchestration 379 Container orchestration ....................................................................................................... 380 Preparing a lab environment for Kubernetes testing .............................................................. 381 Utilizing MicroK8s ................................................................................................................ 383 Installing MicroK8s on Linux • 383 Installing MicroK8s on macOS • 384 Installing MicroK8s on Windows • 386 Interacting with MicroK8s • 390 Setting up a Kubernetes cluster ............................................................................................. 392 Preliminary setup • 393 Installing Kubernetes • 397 Deploying containers via Kubernetes .................................................................................... 402 Summary ............................................................................................................................. 408 Relevant videos .................................................................................................................... 408 Further reading .................................................................................................................... 408 Chapter 19: Deploying Ubuntu in the Cloud 409 Understanding the difference between on-premises and cloud infrastructure ........................ 410 Important considerations when considering cloud computing as a potential solution ............. 411 Becoming familiar with some basic AWS concepts ................................................................. 413 Creating an AWS account ...................................................................................................... 416 Signing up for AWS • 417 Implementing basic user security • 421 Choosing a region ................................................................................................................ 427 Deploying Ubuntu as an AWS EC2 instance ............................................................................ 428 Setting up an IAM role for Session Manager • 428 Creating an Ubuntu Server instance in AWS • 432 Creating and deploying Ubuntu AMIs .................................................................................... 444 Automatically scaling Ubuntu EC2 deployments with Auto Scaling ......................................... 446 Creating a launch template • 447 Creating an Auto Scaling group • 448 Keeping costs down: understanding how to save money and make cost-effective decisions ..... 455 Viewing billing information • 455 Adding a billing alert • 456 Removing unneeded backups • 456 Running EC2 instances only when they’re needed • 456 Stopping or terminating unneeded EC2 instances • 457 Taking the cloud further: additional resources to grow your knowledge ................................. 457 Online training and labs • 457 Certification • 458 Keep experimenting and learning • 458 AWS documentation • 458 Summary ............................................................................................................................. 458 Further reading .................................................................................................................... 459 Chapter 20: Automating Cloud Deployments with Terraform 461 Why it’s important to automate your infrastructure ............................................................... 462 Introduction to Terraform and how it can fit within your workflow ........................................ 463 Installing Terraform ............................................................................................................. 465 Automating an EC2 instance deployment ............................................................................... 470 Managing security groups with Terraform ............................................................................. 476 Using Terraform to destroy unused resources ........................................................................ 479 Combining Ansible with Terraform for a full deployment solution ......................................... 481 Summary ............................................................................................................................. 484 Chapter 21: Securing Your Server 485 Lowering your attack surface ................................................................................................ 485 Understanding and responding to CVEs ................................................................................ 490 Installing security updates ................................................................................................... 490 Automatically installing patches with the Canonical Livepatch service ................................... 494 Securing OpenSSH ............................................................................................................... 495 Installing and configuring Fail2ban ....................................................................................... 498 MariaDB best practices for secure database servers ............................................................... 502 Setting up a firewall .............................................................................................................. 505 Encrypting and decrypting disks with LUKS .......................................................................... 507 Locking down sudo .............................................................................................................. 509 Summary ............................................................................................................................. 510 Further reading .................................................................................................................... 510 Chapter 22: Troubleshooting Ubuntu Servers 511 Evaluating the scope ............................................................................................................. 511 Conducting a root cause analysis ........................................................................................... 513 Viewing system logs ............................................................................................................. 515 Tracing network issues ......................................................................................................... 520 Troubleshooting resource issues ........................................................................................... 524 Diagnosing defective RAM .................................................................................................... 527 Summary ............................................................................................................................. 530 Further reading .................................................................................................................... 530 Chapter 23: Preventing Disasters 531 Preventing disasters ............................................................................................................. 531 Utilizing Git for configuration management ........................................................................... 533 Implementing a backup plan ................................................................................................ 538 Utilizing bootable recovery media ......................................................................................... 540 Summary ............................................................................................................................. 541 Further reading .................................................................................................................... 542 Other Books You May Enjoy 545 Index 549
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum