Book Image

Mastering Ubuntu Server

By : Jay LaCroix
Book Image

Mastering Ubuntu Server

By: Jay LaCroix

Overview of this book

Ubuntu is a Debian-based Linux operating system, and has various versions targeted at servers, desktops, phones, tablets and televisions. The Ubuntu Server Edition, also called Ubuntu Server, offers support for several common configurations, and also simplifies common Linux server deployment processes. With this book as their guide, readers will be able to configure and deploy Ubuntu Servers using Ubuntu Server 16.04, with all the skills necessary to manage real servers. The book begins with the concept of user management, group management, as well as file-system permissions. To manage your storage on Ubuntu Server systems, you will learn how to add and format storage and view disk usage. Later, you will also learn how to configure network interfaces, manage IP addresses, deploy Network Manager in order to connect to networks, and manage network interfaces. Furthermore, you will understand how to start and stop services so that you can manage running processes on Linux servers. The book will then demonstrate how to access and share files to or from Ubuntu Servers. You will learn how to create and manage databases using MariaDB and share web content with Apache. To virtualize hosts and applications, you will be shown how to set up KVM/Qemu and Docker and manage virtual machines with virt-manager. Lastly, you will explore best practices and troubleshooting techniques when working with Ubuntu Servers. By the end of the book, you will be an expert Ubuntu Server user well-versed in its advanced concepts.
Table of Contents (22 chapters)
Mastering Ubuntu Server
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Ubuntu is an exciting platform. You can find it everywhere—desktops, laptops, phones, and especially servers. The Server edition enables administrators to create efficient, flexible, and highly available servers that empower organizations with the power of open source. As Ubuntu administrators, we're in good company—according to W3Techs, Ubuntu is the most widely deployed distribution on the Web in regards to Linux. With the release of Ubuntu 16.04, this platform becomes even more exciting!

In this book, we will dive right into Ubuntu Server and learn all the concepts needed to manage our servers and configure them to perform all kinds of neat tasks, such as serving web pages, managing virtual machines, and sharing data with other users, among many other things. We'll start our journey right in the first chapter, where we'll walk through the installation of Ubuntu Server 16.04, which will serve as the foundation for the rest of the book. As we proceed through the journey, we'll look at managing users, connecting to networks, and controlling processes. Later, we'll implement important technologies such as DHCP, DNS, Apache, and MariaDB, among others. We'll even set up our own ownCloud server along the way.

Finally, the end of the book will cover various things we can do in order to troubleshoot issues, as well as prevent and recover from disasters.

What this book covers

Chapter 1, Deploying Ubuntu Server, covers the installation process for Ubuntu Server. This chapter will walk you through creating bootable media on various operating systems, planning the partition layout, and going through the installation process. Installation on the Raspberry Pi is also covered.

Chapter 2, Managing Users, covers user management in full. Topics here include creating and removing users, password policies, the sudo command, group management, and switching from one user to another.

Chapter 3, Managing Storage Volumes, takes a look at storage volumes. You'll be shown how to view disk usage, format volumes, manage the /etc/fstab file, utilize LVM, and more. In addition, we'll look at managing swap and creating links.

Chapter 4, Connecting to Networks, takes a look at networking in Ubuntu, specifically how to connect to resources from other nodes. We'll look at assigning IP addresses, connecting to other nodes via OpenSSH, using Network Manager, and name resolution.

Chapter 5, Managing Software Packages, takes you through the process of searching for, installing, and managing packages. This will include a look at managing apt repositories, installing packages, and keeping your server up to date. This will even include a look at Snappy packages, which is a promising new package format for Ubuntu systems.

Chapter 6, Controlling and Monitoring Processes, teaches you how to understand what is running on the server, as well as how to stop misbehaving processes. This will include a look at htop, systemd, managing jobs, and understanding load average.

Chapter 7, Managing Your Ubuntu Server Network, revisits networking with more advanced concepts. In this chapter, you will learn more about the technologies that glue your network together, such as DHCP and DNS. In this chapter, you will set up your own DHCP and DNS server and install NTP.

Chapter 8, Accessing and Sharing Files, is all about sharing files with others. Concepts will include the setting up of Samba and NFS network shares and will even go over transferring files manually with rsync and scp.

Chapter 9, Managing Databases, takes you on a journey through setting up and managing databases via MariaDB. You will learn to install MariaDB, set up databases, and create a slave database server.

Chapter 10, Serving Web Content, takes a look at serving content with Apache. In addition, you will be shown how to secure Apache with an SSL certificate, manage modules, and set up keepalived. Setting up OwnCloud is also covered.

Chapter 11, Virtualizing Hosts and Applications, is all about virtualization. You will be walked through setting up your very own KVM installation, as well as utilizing Docker for containing individual applications.

Chapter 12, Securing Your Server, takes a look at various things you can do in order to strengthen security on Ubuntu servers. Topics will include concepts such as lowering the attack surface, securing OpenSSH, and setting up a firewall, among others.

Chapter 13, Troubleshooting Ubuntu Servers, consists of topics relating to things we can do when our deployments don't go exactly according to plan. You will also investigate the problem space, view system logs, and trace network issues.

Chapter 14, Preventing and Recovering from Disasters, informs you of various strategies that can be used to prevent and recover from disasters. This will include a look at utilizing Git for configuration management, implementing a backup plan, creating hard disk images with Clonezilla, and more.

What you need for this book

This book covers Ubuntu Server in depth, and in order to follow along, you'll need to download Ubuntu Server 16.04 and have a machine or two to practice on. It really doesn't matter if you use virtual or physical machines, as the nature of the machine is irrelevant so long as it can run Ubuntu. Virtual machines have the added benefit of snapshots, which you can use to test and roll back modifications to the server.

In the case of virtual machines, it's recommended to use bridged mode for networking so that each VM can see each other easily over the network. It's a good idea to use multiple machines if you can, since several chapters will include networking concepts, such as connecting to other hosts via SSH, setting up a website, and accessing databases.

You'll need to create bootable media in order to install Ubuntu Server. On physical servers, this will require either a blank CD or empty flash drive. In the first chapter, the installation process will be covered and will include a walkthrough on creating bootable media. Ubuntu Server is available online at http://www.ubuntu.com/server.

Since Ubuntu Server doesn't include a graphical user interface by default, it can run on relatively modest hardware. As long as you have 512 MB of RAM and 8 GB of hard disk space available, you should be in good shape. Raspberry Pi users will need an available SD card, preferably 8 GB or larger. Raspberry Pi models 2 and 3 are supported by Ubuntu Server.

Who this book is for

This book is for readers who already have some experience with Linux, though it doesn't necessarily have to be with Ubuntu. Preferably, you have basic Linux command line skills, such as changing directories, listing contents, and issuing commands as regular users or with root. Even if you don't have these skills, you should read this book—the opening chapters will cover many of these concepts.

In this book, we'll take a look at real-world situations in which we can deploy Ubuntu Server. This will include the installation process, serving web pages, setting up databases, and much more. Specifically, the goal here is to be productive. Each chapter will teach you a new and valuable concept, using practical examples that are relative to real organizations. Basically, we focus on getting things done, not primarily on theory. Although the theory that goes into Linux and its many distributions is certainly interesting, the goal here is to get you to the point where if a work colleague or client asks you to perform work on an Ubuntu-based server, you'll be in a good position to get the task done. Therefore, if your goal is to get up and running with Ubuntu Server and learn the concepts that really matter, this book is definitely for you.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "MySQL and MariaDB create their log files in the /var/log/mysql directory."

A block of code is set as follows:

subnet 192.168.1.0 netmask 255.255.255.0 {
       range 192.168.1.100 192.168.1.240; 
       option routers 192.168.1.1; 
       option domain-name-servers 192.168.1.1;

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[Documents]  
        path = /share/documents
        force user = myuser
        force group = users
        public = yes
        writable = no

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Any command line input or output is written as follows:

dpkg --get-selections > installed_packages.txt

Some commands need to be executed as the root user or with sudo. I'll mark these commands with the hash symbol (#) such as in the following example:

# apt-get install openssh-server

If you don't see a hash symbol preceding a command, then sudo or root privileges aren't necessary for you to run it. But if you do see this symbol, take note that you'll need root privileges. I won't always remind you of this beforehand. In most cases, it usually doesn't matter if you use sudo or switch to the root user, I'll leave that up to you. But if it does matter in a particular example, I will let you know.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/MasteringUbuntuServer_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.