O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering Ubuntu Server - Second Edition

Book Description

Get up-to-date with the finer points of Ubuntu Server using this comprehensive guide

About This Book
  • A practical easy-to-understand book that will teach you how to deploy, maintain and troubleshoot Ubuntu Server
  • Get well-versed with newly-added features in Ubuntu 18.04.
  • Learn to manage cutting-edge technologies such as virtualization, containers, Nextcloud and more
Who This Book Is For

This book is intended for readers with intermediate or advanced-beginner skills with Linux, who would like to learn all about setting up servers with Ubuntu Server. This book assumes that the reader knows the basics of Linux, such as editing configuration files and running basic commands.

What You Will Learn
  • Manage users, groups, and permissions
  • Encrypt and decrypt disks with Linux Unified Key Setup (LUKS)
  • Set up SSH for remote access, and connect it to other nodes
  • Add, remove, and search for packages
  • Use NFS and Samba to share directories with other users
  • Get to know techniques for managing Apache and MariaDB
  • Explore best practices and troubleshooting techniques
  • Get familiar with scripting
  • Automate server deployments with Ansible
In Detail

Ubuntu Server has taken the data centers by storm. Whether you're deploying Ubuntu for a large-scale project or for a small office, it is a stable, customizable, and powerful Linux distribution that leads the way with innovative and cutting-edge features. For both simple and complex server deployments, Ubuntu's flexible nature can be easily adapted to meet to the needs of your organization. With this book as your guide, you will learn all about Ubuntu Server, from initial deployment to creating production-ready resources for your network. The book begins with the concept of user management, group management, and filesystem permissions. Continuing into managing storage volumes, you will learn how to format storage devices, utilize logical volume management, and monitor disk usage. Later, you will learn how to virtualize hosts and applications, which will cover setting up KVM/QEMU, as well as containerization with both Docker and LXD. As the book continues, you will learn how to automate configuration with Ansible, as well as take a look at writing scripts. Lastly, you will explore best practices and troubleshooting techniques when working with Ubuntu Server that are applicable to real-world scenarios.

By the end of the book, you will be an expert Ubuntu Server administrator who is well-versed in its advanced concepts.

Style and approach

This book is an advanced guide that will show readers how to administer, manage, and deploy Ubuntu server and will also provide expert-level knowledge on advanced security and backup techniques.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Ubuntu Server Second Edition
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Conventions used
    4. Get in touch
      1. Reviews
  7. Deploying Ubuntu Server
    1. Technical requirements
    2. Setting up our lab
    3. Determining your server's role
    4. Deciding between 32- and 64-bit installations
    5. Obtaining Ubuntu Server installation media
    6. Creating a bootable Ubuntu Server flash drive
    7. Planning the partitioning layout
    8. Installing Ubuntu Server
    9. Installing Ubuntu Server on Raspberry Pi 3
    10. Summary
    11. Questions
    12. Further reading
  8. Managing Users
    1. Understanding when to use root
    2. Creating and removing users
    3. Understanding the /etc/passwd and /etc/shadow files
    4. Distributing default configuration files with /etc/skel
    5. Switching users
    6. Managing groups
    7. Managing passwords and password policies
    8. Configuring administrator access with sudo
    9. Setting permissions on files and directories
    10. Summary
    11. Questions
    12. Further reading
  9. Managing Storage Volumes
    1. Understanding the Linux filesystem
    2. Using symbolic and hard links
    3. Viewing disk usage
    4. Adding additional storage volumes
    5. Partitioning and formatting volumes
    6. Mounting and unmounting volumes
    7. Understanding the /etc/fstab file
    8. Managing swap
    9. Utilizing LVM volumes
    10. Understanding RAID
    11. Summary
    12. Questions
    13. Further reading
  10. Connecting to Networks
    1. Setting the hostname
    2. Managing network interfaces
    3. Assigning static IP addresses
    4. Understanding NetworkManager
    5. Understanding Linux name resolution
    6. Getting started with OpenSSH
    7. Getting started with SSH key management
    8. Simplifying SSH connections with a config file
    9. Summary
    10. Questions
    11. Further reading
  11. Managing Software Packages
    1. Understanding Linux package management
    2. Taking advantage of hardware enablement updates
    3. Understanding the differences between Debian and Snap packages
    4. Installing and removing software
    5. Searching for packages
    6. Managing package repositories
    7. Backing up and restoring Debian packages
    8. Cleaning up orphaned apt packages
    9. Making use of Aptitude
    10. Summary
    11. Questions
  12. Controlling and Monitoring Processes
    1. Showing running processes with the ps command
    2. Managing jobs
    3. Dealing with misbehaving processes
    4. Utilizing htop
    5. Managing system processes
    6. Monitoring memory usage
    7. Scheduling tasks with cron
    8. Understanding load average
    9. Summary
    10. Questions
    11. Further reading
  13. Setting Up Network Services
    1. Planning your IP address scheme
    2. Serving IP addresses with isc-dhcp-server
    3. Setting up DNS with bind
    4. Creating a secondary (slave) DNS server
    5. Setting up an internet gateway
    6. Keeping your clock in sync with NTP
    7. Summary
    8. Questions
    9. Further reading
  14. Sharing and Transferring Files
    1. File server considerations
    2. Sharing files with Windows users via Samba
    3. Setting up NFS shares
    4. Transferring files with rsync
    5. Transferring files with scp
    6. Mounting remote directories with SSHFS
    7. Summary
    8. Questions
    9. Further reading
  15. Managing Databases
    1. Preparations for setting up a database server
    2. Installing MariaDB
    3. Understanding the MariaDB configuration files
    4. Managing MariaDB databases
    5. Setting up a slave database server
    6. Summary
    7. Questions
  16. Serving Web Content
    1. Installing and configuring Apache
    2. Installing additional Apache modules
    3. Securing Apache with SSL
    4. Installing and configuring NGINX
    5. Setting up failover with keepalived
    6. Setting up and configuring Nextcloud
    7. Summary
    8. Questions
    9. Further reading
  17. Learning Advanced Shell Techniques
    1. Understanding the Linux shell
    2. Understanding Bash history
    3. Learning some useful command-line tricks
    4. Redirecting output
    5. Understanding variables
    6. Writing simple scripts
    7. Putting it all together: Writing an rsync backup script
    8. Summary
    9. Questions
    10. Further reading
  18. Virtualization
    1. Setting up a virtual machine server
    2. Creating virtual machines
    3. Bridging the virtual machine network
    4. Simplifying virtual machine creation with cloning
    5. Managing virtual machines via the command line
    6. Summary
    7. Questions
    8. Further reading
  19. Running Containers
    1. What is containerization?
    2. Understanding the differences between Docker and LXD
    3. Installing Docker
    4. Managing Docker containers
    5. Automating Docker image creation with Dockerfiles
    6. Managing LXD containers
    7. Summary
    8. Questions
    9. Further reading
  20. Automating Server Configuration with Ansible
    1. Understanding the need for configuration management
    2. Why Ansible?
    3. Creating a Git repository
    4. Getting started with Ansible
    5. Making your servers do your bidding
    6. Putting it all together – Automating web server deployment
    7. Using Ansible's pull method
    8. Summary
    9. Questions
    10. Further reading
  21. Securing Your Server
    1. Lowering your attack surface
    2. Understanding and responding to CVEs
    3. Installing security updates
    4. Automatically installing patches with the Canonical Livepatch service
    5. Monitoring Ubuntu servers with Canonical's Landscape service
    6. Securing OpenSSH
    7. Installing and configuring Fail2ban
    8. MariaDB best practices for secure database servers
    9. Setting up a firewall
    10. Encrypting and decrypting disks with LUKS
    11. Locking down sudo
    12. Summary
    13. Questions
    14. Further reading
  22. Troubleshooting Ubuntu Servers
    1. Evaluating the problem space
    2. Conducting a root cause analysis
    3. Viewing system logs
    4. Tracing network issues
    5. Troubleshooting resource issues
    6. Diagnosing defective RAM
    7. Summary
    8. Questions
  23. Preventing and Recovering from Disasters
    1. Preventing disasters
    2. Utilizing Git for configuration management
    3. Implementing a backup plan
    4. Replacing failed RAID disks
    5. Utilizing bootable recovery media
    6. Summary
    7. Questions
    8. Further Reading
  24. Using the Alternate Installer
    1. Obtaining the Alternate Installer
    2. Installing via the Alternate Installer
    3. Setting up software RAID
    4. Summary
  25. Assessments
    1. Chapter 1 – Deploying Ubuntu Server
    2. Chapter 2 – Managing Users
    3. Chapter 3 – Managing Storage Volumes
    4. Chapter 4 – Connecting to Networks
    5. Chapter 5 – Managing Software Packages
    6. Chapter 6 – Controlling and Monitoring Processes
    7. Chapter 7 – Setting Up Network Services
    8. Chapter 8 - Accessing and sharing files
    9. Chapter 9 - Sharing and Transferring Files
    10. Chapter 10 – Serving Web Content
    11. Chapter 11 – Learning Advanced Shell Techniques
    12. Chapter 12 – Virtualization
    13. Chapter 13 – Running Containers
    14. Chapter 14 – Automating Server Configuration with Ansible
    15. Chapter 15 – Securing Your Server
    16. Chapter 16 – Troubleshooting Ubuntu Servers
    17. Chapter 17 – Preventing and Recovering from Disasters
  26. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think