Practical Linux Topics
Total Page:16
File Type:pdf, Size:1020Kb
Binnie BOOKS FOR PROFESSIONALS BY PROFESSIONALS® THE EXPERT’S VOICE® IN LINUX Practical Linux Topics Practical Practical Linux Topics This book teaches you how to improve your hands-on knowledge of Linux using challenging, real-world scenarios. Each chapter explores a topic that has been chosen specifically to demonstrate how to enhance your base Linux system, and resolve important issues. This book enables sysadmins, DevOps engineers, developers, and other technical professionals to make full use of Linux’s rocksteady foundation. Practical Linux Explore specific topics in networking, e-mail, filesystems, encryption, system monitoring, security, servers, and more—including systemd and GPG. Understand salient security concerns and how to mitigate them. Applicable to almost all Linux flavors—Debian, Red Hat, Ubuntu, Linux Mint, CentOS—Power Linux Topics can be used to reference other Unix-type systems Topics with little modification. Improve your practical know-how and background knowledge on servers and workstations alike, increase your ability to troubleshoot and ultimately solve the daily challenges encountered — by all professional Linux users. Empower your Linux skills by adding Power Linux Topics to your library today. Chris Binnie US . ISBN 978-1-4842-1771-9 Shelve in: 54999 Linux/General User level: Intermediate–Advanced 9781484 217719 SOURCE CODE ONLINE www.apress.com Practical Linux Topics Chris Binnie Practical Linux Topics Copyright © 2016 by Chris Binnie This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN-13 (pbk): 978-1-4842-1771-9 IISBN-13 (electronic): 978-1-4842-1772-6 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: Louise Corrigan Development Editor: James Markham Technical Reviewer: Sander van Vugt Editorial Board: Steve Anglin, Pramila Balen, Louise Corrigan, Jim DeWolf, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Michelle Lowman, James Markham, Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing Coordinating Editor: Jill Balzano Copy Editor: Kezia Endsley Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this text is available to readers at www.apress.com/. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/. Dedicated to systems that say, without providing any other details, “There has been an error”, my long-suffering better half, and my two beautiful children, without whom this book would have been finished earlier. Contents at a Glance About the Author .....................................................................................................xv About the Technical Reviewer ...............................................................................xvii Introduction ............................................................................................................xix ■ Chapter 1: Real-Time Network Statistics with Iftop .............................................. 1 ■ Chapter 2: Destroying Sensitive Data .................................................................. 13 ■ Chapter 3: Supercharged systemd ...................................................................... 21 ■ Chapter 4: Zero Downtime Linux ......................................................................... 33 ■ Chapter 5: Get More with Wget............................................................................ 41 ■ Chapter 6: SECURING SSH with PAM .................................................................... 51 ■ Chapter 7: Your Disks, Your Way ......................................................................... 61 ■ Chapter 8: No sFTP Doesn’t Mean No Encryption ................................................ 71 ■ Chapter 9: Making the Most of the Screen Utility ................................................ 83 ■ Chapter 10: Improve Security with SELinux ........................................................ 91 ■ Chapter 11: Nattier Networks ............................................................................ 105 ■ Chapter 12: Keeping Information Private with GPG ........................................... 115 ■ Chapter 13: Get Permission from Your Peers with Sudo ................................... 127 ■ Chapter 14: Loop Disks and Wubi ...................................................................... 135 ■ Appendix A: Hack, Break, Fix ............................................................................. 143 Index ..................................................................................................................... 149 v Contents About the Author .....................................................................................................xv About the Technical Reviewer ...............................................................................xvii Introduction ............................................................................................................xix ■ Chapter 1: Real-Time Network Statistics with Iftop .............................................. 1 Monitoring Network Connections with netstat ����������������������������������������������������������������� 1 Introducing iftop ��������������������������������������������������������������������������������������������������������������� 3 Installing iftop ������������������������������������������������������������������������������������������������������������������ 4 Controlling iftop from the Keyboard ��������������������������������������������������������������������������������� 5 Adding Screen Filters ������������������������������������������������������������������������������������������������������� 8 Using Regular Expressions ����������������������������������������������������������������������������������������������� 8 Listening for Network Traffic ������������������������������������������������������������������������������������������ 10 Changing Filters Can Take Time ������������������������������������������������������������������������������������� 11 Configuring iftop Scenarios �������������������������������������������������������������������������������������������� 11 Using iftop on Busy Routers ������������������������������������������������������������������������������������������� 12 Summary ������������������������������������������������������������������������������������������������������������������������ 12 ■ Chapter 2: Destroying Sensitive Data .................................................................. 13 A Note on Random Data Overwrites and Degaussing ���������������������������������������������������� 13 Using the shred Utility ����������������������������������������������������������������������������������������������������