Hands-On Linux Administration on Azure
Total Page:16
File Type:pdf, Size:1020Kb
Hands-On Linux Administration on Azure Explore the essential Linux administration skills you need to deploy and manage Azure-based workloads Frederik Vos BIRMINGHAM - MUMBAI Hands-On Linux Administration on Azure Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Vijin Boricha Acquisition Editor: Rahul Nair Content Development Editor: Nithin George Varghese Technical Editor: Komal Karne Copy Editor: Safis Editing Project Coordinator: Drashti Panchal Proofreader: Safis Editing Indexer: Mariammal Chettiyar Graphics: Tom Scaria Production Coordinator: Deepika Naik First published: August 2018 Production reference: 1310818 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78913-096-6 www.packtpub.com mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Contributors About the author Frederik Vos, living in Purmerend, a city near Amsterdam in the Netherlands, works as a senior technical trainer of virtualization technologies, such as Citrix XenServer, and VMware vSphere. He specializes in data center infrastructures (hypervisor, network, and storage) and cloud computing (CloudStack, CloudPlatform, OpenStack, and Azure). He is also a Linux trainer and evangelist. He has a lot of knowledge as a teacher and also real- world experience as a system administrator. For the last three years he has been working as a freelance trainer and consultant within the ITGilde Cooperation, delivering many Linux training, such as Linux on Azure training for the Linux Foundation. I really enjoyed working on this book! However, writing would not have been possible without the help of my wife, Carola Dahmen. During all the hours that I wasn't available, she did the hard job of keeping everything running at home! I want to thank Packt Publishing, especially Nithin George, Varghese, and Rahul Nair for their patience and for believing me, even with the big delay caused by my move to another city. Thanks to everyone who supported me in terms of knowledge and ideas, especially Sander van Vugt, Pascal van Dam, and several Microsoft employees. About the reviewers Toni Willberg is a Linux on Azure subject matter expert with over 20 years of professional IT experience. His career started in 1997 as software developer and Linux sysadmin. Currently, Toni works with Microsoft as cloud solution architect, specializing in Azure infrastructure services. Prior to Microsoft, he was with Red Hat for eight years, working as solution architect focusing on Red Hat Enterprise Linux and related infrastructure technologies. Sander van Vugt is a Linux expert and author living in the Netherlands. Sander has published different Linux-related titles and teaches classes for customers around the world. Sander is also the Director of ITGilde Academy. Pascal van Dam has a bachelor's degree in Computer Science and has had his first experiences with Linux and the open source world as early as 1993. He's a HP-UX, AIX, and Linux Foundation trainer. As a Linux Foundation trainer he has had the honor to bring the Story of Linux and Open Source on Azure to many Microsoft colleagues in the world. Currently, Pascal is the Cloud Linux Architect for ATOS for both the on-premise and the public clouds such as Azure. At home, Pascal has six sons together with his love in lively home full of energy. Pascal strongly believes in having an open mind with an open view in an open world. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface 1 Chapter 1: Exploring the Azure Cloud 7 Fundamentals of cloud computing 7 Virtualization 8 Software-Defined Datacenter 9 SOA 10 Cloud services 11 Cloud types 11 Understanding the Azure Cloud 12 A small history of the Azure Cloud 12 Azure architecture 13 Azure in your organization 14 Azure and open source 14 Summary 15 Questions 16 Further reading 16 Chapter 2: Getting Started with the Azure Cloud 17 Technical requirements 17 Getting access to Azure 18 Logging in using the Azure portal 18 Getting command-line access to Azure 19 Installing the Azure command-line interface 19 Logging in with the Azure CLI 20 PowerShell 23 Logging in with PowerShell 25 Azure Resource Manager 27 Linux and Azure 29 Linux distributions 29 Microsoft-endorsed Linux distributions 30 Deploying a Linux virtual machine 31 Your first virtual machine 31 Images 32 Image sizing 33 Virtual machine networking 34 Virtual machine information 34 Connecting to Linux 36 Logging in to your Linux VM using password authentication 36 Logging in to your Linux VM with an SSH private key 37 Table of Contents Summary 38 Questions 39 Further reading 39 Chapter 3: Basic Linux Administration 40 The Linux shell 40 Executing commands 41 Command-line editing 43 Working with history 44 Auto-completion 45 Globbing 46 Redirections 47 Working with variables 49 Bash configuration files 50 Getting help 52 Using the man-pages 52 Using info documents 54 Other documentation 55 Working with text files 55 Reading text 56 Searching in text files 57 Editing text files 60 Finding your way in the filesystem 61 File hierarchy system 62 Mounting filesystems 65 Finding files on the filesystem 67 Process management 68 View processes 68 Sending signals to a process 71 Discretionary Access Control 72 User management 72 Group management 75 Login management 76 Summary 78 Questions 79 Further reading 79 Chapter 4: Managing Azure 81 Technical requirements 81 Storage services 82 Storage accounts 83 Managed disks 86 Azure Files 89 Blob storage 92 Networking 95 [ ii ] Table of Contents Virtual network 95 Subnets 96 Network Security Group 99 Public IP address and network interface 102 Components for your virtual machine 104 Azure profile 104 Resource group 104 Storage account 105 Virtual network 105 NSG 105 Public IP address and network interface 106 Summary 106 Questions 107 Further reading 107 Chapter 5: Advanced Linux Administration 108 Technical requirements 108 Software management 108 The RPM software manager 109 The DPKG software manager 112 Software management with YUM 113 Software management with Zypp 115 Software management with apt 118 Networking 119 Identifying the network interfaces 119 Identifying the IP address 121 Showing the route table 121 Network configuration 122 Changes in the network configuration 124 Hostname 125 DNS 126 Storage 127 Storage provided by block devices 127 Adding a data disk 129 Partitioning 131 Filesystems in Linux 132 Ext4 filesystem 133 XFS filesystem 134 ZFS filesystem 135 BTRFS filesystem 136 Swap filesystem 138 Linux software RAID 139 Systemd 140 Working with units 140 Services 141 Targets 144 [ iii ] Table of Contents Scheduled tasks 144 Mounting local filesystems 145 Mounting remote filesystems 146 Summary 146 Questions 147 Further reading 147 Chapter 6: Managing Linux Security and Identities 149 Linux security tips 150 Technical requirements 151 Linux firewall 152 Firewalld zones 153 Firewalld services 155 Firewalld network sources 156 Linux Security Modules 158 SELinux 158 SELinux configuration 159 SELinux context on ports 160 SELinux context on files 163 SELinux Boolean 165 AppArmor 166 AppArmor status 167 Generating AppArmor profiles 168 Systemd security 172 Restricting access to the filesystem 172 Restricting network access 173 Azure Active Directory Domain Service 175 Setting