ENGLISH

Linux Administration Cookbook: Insightful Recipes To Work With System Administration Tasks On Linux

Book information

Publisher
Packt Publishing
Year
2018
ISBN
178934252X, 9781789342529
Language
english
Format
PDF
Filesize
45 MB (47408645 bytes)
Pages
818\818
Topic
Computers\\Operating Systems
Time added
2019-06-20 11:46:52

Description

Understand and implement the core system administration tasks in Linux. Discover tools and techniques to troubleshoot your Linux system. Maintain a healthy system with good security and backup practices. 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. What you will learn: Install and manage a Linux server, both locally and in the cloud. Understand how to perform administration across all Linux distros. Work through evolving concepts such as IaaS versus PaaS, containers, and automation. Explore security and configuration best practices. Troubleshoot your system if something goes wrong. Discover and mitigate hardware issues, such as faulty memory and failing drives. Who this book is for: If you are a system engineer or system administrator with basic experience of working with Linux, this book is for you. Cover......Page 1 Title Page......Page 2 Copyright and Credits......Page 3 About Packt......Page 4 Contributors......Page 5 Table of Contents......Page 7 Preface......Page 27 Introduction......Page 33 Understanding and choosing a distribution......Page 34 Ubuntu......Page 35 Debian......Page 37 CentOS – the one we'll mostly be using......Page 38 Red Hat Enterprise Linux......Page 39 Installing VirtualBox......Page 40 Command-line installation......Page 41 Graphical installation......Page 42 Graphical installation......Page 43 Graphical installation......Page 44 Obtaining our CentOS installation media......Page 45 Checking the checksum......Page 47 Setting up our VM......Page 48 VirtualBox main window......Page 49 CentOS installation......Page 50 Accessing and updating our VM......Page 58 Logging in from the VirtualBox window......Page 59 Logging in from the host Terminal......Page 61 Making sure that VirtualBox lets us through......Page 62 Updating our VM......Page 65 dmidecode......Page 67 lshw......Page 70 Quick sudo explanation......Page 72 Using Vagrant to automatically provision VMs......Page 73 Vagrant......Page 74 Anecdote – try, try, and try again......Page 78 Introduction......Page 81 Technical requirements......Page 82 Generating and using key pairs with ssh-keygen......Page 83 Getting ready......Page 85 RSA example......Page 86 Ed25519 example......Page 88 How it works…......Page 89 The public and private key files......Page 90 The authorized_keys file......Page 92 There's more.........Page 94 Additional flags......Page 95 See also......Page 96 SSH using hostnames instead of IPs......Page 97 SSHing to a different port......Page 98 SSHing to an IPv6 address......Page 99 SSH and X11 forwarding......Page 100 There's more…......Page 101 Getting ready......Page 102 How to do it…......Page 103 How it works…......Page 104 There's more…......Page 109 Getting ready......Page 110 Changing the default port......Page 111 Changing the listen address......Page 113 Changing the daemon logging level......Page 114 Disallowing root login......Page 115 Setting a message of the day (motd)......Page 116 The UseDNS setting......Page 117 How it works…......Page 118 See also......Page 119 Getting ready......Page 120 How to do it…......Page 122 There's more…......Page 124 Getting ready......Page 125 On the command line......Page 126 Using an SSH config file......Page 127 How it works…......Page 128 Watching our SSH session......Page 129 See also......Page 130 On the command line......Page 131 How it works…......Page 132 There's more…......Page 133 See also......Page 134 How to do it…......Page 135 How it works…......Page 136 Multiple hosts......Page 139 ProxyCommand......Page 140 Bastion hosts......Page 141 Using SSH to create a SOCKS Proxy......Page 142 On the command line......Page 143 Using an SSH config file......Page 144 How it works…......Page 145 Understanding and using SSH agents......Page 147 Getting ready......Page 148 How to do it…......Page 149 There's more…......Page 151 ssh-add......Page 152 See also......Page 153 How to do it…......Page 154 How it works…......Page 156 There's more…......Page 157 Summary......Page 158 Introduction......Page 160 Technical requirements......Page 161 Determining our network configuration......Page 162 Discerning the IP......Page 163 Discerning the IP (deprecated method)......Page 165 Discerning the gateway address......Page 166 There's more…......Page 167 Checking what route our box will take......Page 168 Adding and removing an IP against an interface......Page 170 Shutting down and bringing up an interface administratively......Page 171 Adding a new route to our routing table......Page 172 How it works…......Page 173 There's more…......Page 174 Getting ready......Page 175 Configuring a new interface......Page 176 How it works…......Page 177 There's more…......Page 178 Modern domain name resolution on Linux......Page 179 Querying a domain......Page 180 Checking the domain resolution settings......Page 181 Changing the domain resolution settings......Page 182 How it works…......Page 183 There's more…......Page 184 Configuring NTP and the problems we face......Page 185 How to do it…......Page 186 Checking if NTP traffic is flowing......Page 187 Enabling an NTP client......Page 189 Enabling an NTP server......Page 190 How it works…......Page 191 There's more…......Page 192 Listing firewall rules on the command line......Page 193 iptables......Page 194 firewall-cmd......Page 198 ufw......Page 199 See also......Page 200 firewall-cmd......Page 201 iptables......Page 203 ufw......Page 204 How it works…......Page 205 There's more…......Page 206 Getting ready......Page 208 How to do it…......Page 209 How it works…......Page 212 There's more…......Page 213 Getting ready......Page 214 How to do it…......Page 215 There's more…......Page 217 Summary......Page 218 Introduction......Page 221 Technical requirements......Page 222 Determining running services......Page 223 How to do it…......Page 224 How it works…......Page 226 Getting ready......Page 227 How it works…......Page 228 There's more…......Page 229 Starting and stopping services......Page 231 Starting our service......Page 232 There's more…......Page 233 How to do it…......Page 234 Enabling our service......Page 235 There's more…......Page 236 chronyd.service......Page 237 postfix.service......Page 238 How it works…......Page 239 Understanding service unit files......Page 240 How to do it…......Page 241 How it works…......Page 243 How to do it…......Page 244 How it works…......Page 245 There's more…......Page 246 Getting ready......Page 247 How to do it…......Page 248 How to do it…......Page 249 There's more…......Page 251 Working with systemd timers (and cron)......Page 253 systemd timers......Page 254 cron......Page 255 There's more…......Page 257 See also......Page 259 CentOS 6 and Upstart......Page 260 Debian 7 and SysV init......Page 262 How it works…......Page 263 Round-up – services and daemons......Page 264 Introduction......Page 266 Technical requirements......Page 267 Getting ready......Page 268 lspci......Page 269 lshw......Page 272 /proc......Page 275 /sys......Page 277 dmesg (and the kernel logs)......Page 278 dmidecode......Page 279 /dev......Page 280 Testing hardware......Page 283 Self-monitoring, analysis, and reporting technology (SMART)......Page 284 hdparm......Page 285 Memory testing......Page 286 There's more…......Page 288 How to do it…......Page 289 How it works…......Page 294 Getting ready......Page 295 Listing disks with lsblk......Page 296 Listing mount points with df......Page 297 Listing filesystems with df......Page 298 Physical disks......Page 299 Volume groups......Page 300 Logical volumes......Page 301 Listing swap......Page 302 How it works…......Page 303 There's more…......Page 304 How to do it…......Page 305 How it works…......Page 306 There's more…......Page 307 How to do it…......Page 308 How it works…......Page 312 There's more…......Page 313 Getting ready......Page 314 How to do it…......Page 315 There's more…......Page 317 Getting ready......Page 319 fstab......Page 320 systemd-mount......Page 321 How it works…......Page 322 See also......Page 323 Getting ready......Page 324 How to do it…......Page 325 How it works…......Page 327 There's more…......Page 328 See also......Page 329 Current filesystem formats......Page 330 How to do it…......Page 331 How it works…......Page 332 How to do it…......Page 333 How it works…......Page 334 Round-up – hardware and disks......Page 335 Introduction......Page 336 Technical requirements......Page 337 Checking package versions......Page 338 CentOS......Page 339 Debian......Page 343 How it works…......Page 347 There's more…......Page 348 CentOS......Page 349 Debian......Page 352 Ubuntu......Page 353 There's more…......Page 356 Checking for updates......Page 357 CentOS......Page 358 Debian......Page 361 There's more…......Page 364 CentOS......Page 365 Debian......Page 369 How it works…......Page 371 Automatic provisioning......Page 373 How to do it…......Page 374 Package changelogs......Page 375 Official sources and mailing Lists......Page 377 Other sources......Page 378 Using snaps......Page 379 Searching out snaps......Page 380 Interacting with daemon snaps......Page 381 Removing snaps......Page 382 How it works…......Page 383 There's more…......Page 384 See also.........Page 385 Getting ready......Page 387 Installing our package......Page 388 Running our package......Page 389 Removing packages......Page 390 There's more…......Page 391 Getting ready......Page 392 Pip......Page 393 RubyGems......Page 395 When to use programming-language package managers......Page 397 See also......Page 398 Getting ready......Page 399 System-installed and third-party installed versions of Pip......Page 400 Dependency problems in conflicting Pip packages......Page 401 Apt's conflict solution......Page 402 Potential solutions......Page 403 Getting ready......Page 404 How to do it…......Page 405 How it works…......Page 412 See also.........Page 413 How to do it…......Page 414 CentOS – Adding the EPEL repository with epel-release......Page 415 CentOS – Adding the ELRepo repository by file......Page 416 Debian – Adding additional repositories......Page 419 Ubuntu – Adding PPAs......Page 421 Roundup – security, updating, and package management......Page 422 Introduction......Page 424 Technical requirements......Page 425 Reading local logs......Page 426 How to do it…......Page 427 How it works…......Page 430 There's more…......Page 433 How to do it…......Page 434 How it works…......Page 440 There's more…......Page 441 Centralizing logging......Page 442 How to do it…......Page 443 Remote logging with rsyslog – UDP example......Page 444 Remote logging with rsyslog – TCP example......Page 445 Remote logging with journald......Page 446 There's more…......Page 448 Local resource measuring tools......Page 449 top......Page 450 free......Page 454 htop......Page 455 NetData......Page 457 How it works…......Page 458 There's more…......Page 459 atop......Page 460 sar......Page 463 vmstat......Page 464 How it works…......Page 465 Remote monitoring tools......Page 466 Nagios......Page 467 Icinga2......Page 472 There's more…......Page 490 See also......Page 491 Getting ready......Page 492 How to do it…......Page 493 debian1 and debian2......Page 495 Kibana......Page 496 How it works…......Page 499 There's more…......Page 500 Roundup – Monitoring and Logging......Page 501 Introduction......Page 503 Technical requirements......Page 504 How to do it…......Page 505 exampledir......Page 506 examplefile......Page 507 Other execute characters......Page 508 chown......Page 510 chattr......Page 512 chmod......Page 513 Avoiding octal notation (if you hate it) in chmod......Page 514 Hierarchical permissions......Page 515 See also......Page 516 Users and groups......Page 517 Users on a system......Page 518 Groups on a system......Page 520 Daemons using users......Page 521 There's more…......Page 522 How to do it…......Page 523 How it works…......Page 525 There's more…......Page 526 SELinux and modification......Page 527 How to do it…......Page 528 How it works…......Page 532 Checking SELinux is running, and the importance of keeping it running......Page 534 How to do it…......Page 535 How it works…......Page 539 See also......Page 540 How to do it…......Page 541 There's more…......Page 543 Roundup – permissions, SELinux, and AppArmor......Page 544 Introduction......Page 546 What is a container?......Page 548 How to do it…......Page 549 namespaces......Page 551 The breakdown of our creation......Page 552 The LXD daemon......Page 553 Installing Docker......Page 554 How to do it…......Page 555 How it works…......Page 556 There's more…......Page 558 Getting ready......Page 559 How to do it…......Page 560 Creating a container......Page 561 Executing commands in our container......Page 562 How to do it…......Page 563 There's more…......Page 565 How to do it…......Page 566 How it works…......Page 571 What is virtualization?......Page 573 How to do it…......Page 574 How it works…......Page 576 Starting a QEMU machine with our VM......Page 577 How to do it…......Page 578 How it works…......Page 581 There's more…......Page 582 See also......Page 583 virt-install......Page 584 virsh......Page 585 How it works…......Page 589 There's more…......Page 590 How to do it…......Page 591 Local Nginx install......Page 592 Docker Nginx install......Page 593 VM Nginx install......Page 594 How it works…......Page 595 VMware ESXi......Page 596 Proxmox Virtual Environment......Page 598 OpenStack......Page 599 How it works…......Page 601 Roundup – containers and virtualization......Page 602 Introduction......Page 604 Technical requirements......Page 605 Getting ready......Page 606 Exploring and making changes......Page 607 How it works…......Page 610 There's more…......Page 612 Getting ready......Page 614 How it works…......Page 615 There's more…......Page 616 Getting ready......Page 617 How to do it…......Page 618 Matching versus simple......Page 620 How to do it…......Page 621 How it works…......Page 625 There's more…......Page 627 Installing Ansible......Page 628 How to do it…......Page 629 How it works…......Page 634 The raw module......Page 637 The shell and command modules......Page 638 Getting ready......Page 639 How to do it…......Page 640 How it works…......Page 642 There's more…......Page 644 Getting ready......Page 646 How it works…......Page 647 Exploring options for IaC......Page 648 Getting ready......Page 649 Terraform......Page 650 Packer......Page 654 How it works…......Page 656 There's more…......Page 660 Roundup – Git, Configuration Management, and Infrastructure as Code......Page 661 Introduction......Page 664 Installing and understanding a web server......Page 666 Getting ready......Page 667 Installing httpd (Apache) on CentOS......Page 668 Installing Nginx on Debian......Page 669 How it works…......Page 670 Basic Apache configuration......Page 671 How to do it…......Page 672 How it works…......Page 675 There's more…......Page 676 Basic Nginx configuration......Page 677 How to do it…......Page 678 How it works…......Page 680 See also......Page 682 SSL, TLS, and LetsEncrypt......Page 683 How to do it…......Page 685 How it works…......Page 687 There's more…......Page 688 See also......Page 689 Basic MySQL or MariaDB Installation......Page 690 How to do it…......Page 691 Listing, creating, and selecting databases and tables......Page 692 How it works…......Page 695 Basic PostgreSQL installation......Page 696 Listing, creating, and selecting databases and tables......Page 697 How it works…......Page 699 Local MTA usage and configuration (Postfix)......Page 700 Getting ready......Page 701 How to do it…......Page 702 /etc/aliases......Page 704 How it works…......Page 705 There's more…......Page 707 Local MTA usage and configuration (Exim)......Page 708 How to do it…......Page 709 How it works…......Page 711 NoSQL documents (MongoDB example)......Page 715 Getting ready......Page 716 How to do it…......Page 717 How it works…......Page 720 There's more…......Page 721 Getting ready......Page 722 How to do it…......Page 723 How it works…......Page 724 Messaging brokers and queues (RabbitMQ example)......Page 725 How to do it…......Page 727 How it works…......Page 730 Roundup – web servers, databases, and mail servers......Page 731 Super personal preference time!......Page 733 Introduction......Page 734 Technical requirements......Page 735 How to do it…......Page 736 Getting ready......Page 737 How to do it…......Page 738 Getting ready......Page 740 How to do it…......Page 741 Using ss, iftop, tcpdump, and others for network issues......Page 742 Ping......Page 743 ss......Page 745 iftop......Page 746 tcpdump......Page 748 Using cURL, wget, and OpenSSL for remote web issues......Page 749 How to do it…......Page 750 cURL......Page 751 Wget......Page 753 OpenSSL......Page 755 How to do it…......Page 760 iotop......Page 761 top......Page 764 vmstat......Page 765 Getting ready......Page 766 ps......Page 767 lsof......Page 768 Strace......Page 769 Making a copy of problems for later debugging......Page 771 How to do it…......Page 772 Temporary solutions and when to invoke them......Page 773 How to do it…......Page 774 Handling irate developers......Page 775 How to do it…......Page 776 How to do it…......Page 777 Handling irate business owners......Page 778 Don't trust time......Page 779 On "cloud" deployments......Page 780 Learn from my mistakes......Page 781 Introduction......Page 782 How to do it…......Page 783 The filesystem check......Page 784 How it works…......Page 785 Understanding how the BSDs differ......Page 786 FreeBSD......Page 787 OpenBSD......Page 789 The differences......Page 791 Oracle Solaris......Page 792 illumos......Page 793 The differences......Page 794 IaaS (Infrastructure as a Service)......Page 796 IaaS providers and features......Page 797 PaaS (Platform as a Service)......Page 798 PaaS providers and features......Page 799 The Ops versus DevOps Wars......Page 800 More of a skirmish, really......Page 802 Roundup – BSDs, Solaris, Windows, IaaS and PaaS, DevOps......Page 803 Other Books You May Enjoy......Page 805 Index......Page 808

Similar books