Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Using and administering Linux. Volume 2
Nội dung xem thử
Mô tả chi tiết
Using and
Administering
Linux: Volume 2
Zero to SysAdmin: Advanced Topics
—
David Both
Using and Administering
Linux: Volume 2
Zero to SysAdmin: Advanced Topics
David Both
Using and Administering Linux: Volume 2
ISBN-13 (pbk): 978-1-4842-5454-7 ISBN-13 (electronic): 978-1-4842-5455-4
https://doi.org/10.1007/978-1-4842-5455-4
Copyright © 2020 by David Both
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.
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, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Louise Corrigan
Development Editor: James Markham
Coordinating Editor: Nancy Chen
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
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 orders-ny@springersbm.com, 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 http://www.apress.com/
rights-permissions.
Apress titles 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 Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book's product page, located at www.apress.com/9781484254547. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
David Both
Raleigh, NC, USA
This book – this course – is dedicated to all Linux and
open source course developers and trainers.
:(){ :|:& };:
v
Chapter 1: Logical Volume Management������������������������������������������������������������������ 1
Objectives ������������������������������������������������������������������������������������������������������������������������������������� 1
The need for logical volume management������������������������������������������������������������������������������������ 1
Running out of disk space in VirtualBox ���������������������������������������������������������������������������������� 2
Recovery���������������������������������������������������������������������������������������������������������������������������������� 2
LVM structure�������������������������������������������������������������������������������������������������������������������������������� 3
Extending a logical volume ����������������������������������������������������������������������������������������������������������� 4
Extending volume groups ������������������������������������������������������������������������������������������������������������� 7
Create a new volume group – 1 ���������������������������������������������������������������������������������������������� 7
Create a new volume group – 2 �������������������������������������������������������������������������������������������� 11
Tips ��������������������������������������������������������������������������������������������������������������������������������������������� 13
Advanced capabilities ����������������������������������������������������������������������������������������������������������������� 14
Chapter summary ����������������������������������������������������������������������������������������������������������������������� 14
Exercises������������������������������������������������������������������������������������������������������������������������������������� 15
Chapter 2: File Managers ��������������������������������������������������������������������������������������� 17
Objectives ����������������������������������������������������������������������������������������������������������������������������������� 17
Introduction��������������������������������������������������������������������������������������������������������������������������������� 17
Text-mode interface �������������������������������������������������������������������������������������������������������������� 18
Graphical interface ���������������������������������������������������������������������������������������������������������������� 18
Table of Contents
About the Author ����������������������������������������������������������������������������������������������������xix
About the Technical Reviewer ��������������������������������������������������������������������������������xxi
Acknowledgments������������������������������������������������������������������������������������������������xxiii
Introduction�����������������������������������������������������������������������������������������������������������xxv
vi
Default file manager ������������������������������������������������������������������������������������������������������������������� 18
Text-mode file managers ������������������������������������������������������������������������������������������������������������ 20
Midnight Commander������������������������������������������������������������������������������������������������������������ 20
Other text-mode file managers��������������������������������������������������������������������������������������������������� 31
Vifm ��������������������������������������������������������������������������������������������������������������������������������������� 31
nnn ���������������������������������������������������������������������������������������������������������������������������������������� 32
Graphical file managers�������������������������������������������������������������������������������������������������������������� 33
Krusader�������������������������������������������������������������������������������������������������������������������������������� 34
Thunar����������������������������������������������������������������������������������������������������������������������������������������� 37
Dolphin���������������������������������������������������������������������������������������������������������������������������������������� 38
XFE���������������������������������������������������������������������������������������������������������������������������������������������� 40
Chapter summary ����������������������������������������������������������������������������������������������������������������������� 41
Exercises������������������������������������������������������������������������������������������������������������������������������������� 41
Chapter 3: Everything Is a File�������������������������������������������������������������������������������� 43
Objectives ����������������������������������������������������������������������������������������������������������������������������������� 43
What is a file? ����������������������������������������������������������������������������������������������������������������������������� 43
Device files���������������������������������������������������������������������������������������������������������������������������������� 44
Device file creation���������������������������������������������������������������������������������������������������������������� 45
udev simplification���������������������������������������������������������������������������������������������������������������������� 45
Naming rules ������������������������������������������������������������������������������������������������������������������������� 46
Device data flow ������������������������������������������������������������������������������������������������������������������������� 47
Device file classification ������������������������������������������������������������������������������������������������������������� 48
Fun with device files������������������������������������������������������������������������������������������������������������������� 50
Randomness, zero, and more������������������������������������������������������������������������������������������������������ 55
Back up the master boot record ������������������������������������������������������������������������������������������������� 58
Implications of everything is a file���������������������������������������������������������������������������������������������� 65
Chapter summary ����������������������������������������������������������������������������������������������������������������������� 65
Exercises������������������������������������������������������������������������������������������������������������������������������������� 66
Table of Contents
vii
Chapter 4: Managing Processes����������������������������������������������������������������������������� 67
Objectives ����������������������������������������������������������������������������������������������������������������������������������� 67
Processes������������������������������������������������������������������������������������������������������������������������������������ 67
Process scheduling in the kernel ������������������������������������������������������������������������������������������ 67
Tools�������������������������������������������������������������������������������������������������������������������������������������������� 68
top ����������������������������������������������������������������������������������������������������������������������������������������� 69
More about load averages… ������������������������������������������������������������������������������������������������������ 75
…and signals ������������������������������������������������������������������������������������������������������������������������ 76
CPU hogs������������������������������������������������������������������������������������������������������������������������������������� 77
Process scheduling��������������������������������������������������������������������������������������������������������������������� 79
Nice numbers ������������������������������������������������������������������������������������������������������������������������ 79
Killing processes������������������������������������������������������������������������������������������������������������������������� 82
Other interactive tools����������������������������������������������������������������������������������������������������������������� 83
atop ��������������������������������������������������������������������������������������������������������������������������������������� 83
htop ��������������������������������������������������������������������������������������������������������������������������������������� 86
Glances���������������������������������������������������������������������������������������������������������������������������������� 93
Other tools ����������������������������������������������������������������������������������������������������������������������������� 96
The impact of measurement����������������������������������������������������������������������������������������������������� 102
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 102
Exercises����������������������������������������������������������������������������������������������������������������������������������� 103
Chapter 5: Special Filesystems ���������������������������������������������������������������������������� 105
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 105
Introduction������������������������������������������������������������������������������������������������������������������������������� 105
The /proc filesystem ����������������������������������������������������������������������������������������������������������������� 106
The /sys filesystem�������������������������������������������������������������������������������������������������������������� 116
Swap space������������������������������������������������������������������������������������������������������������������������������� 121
Types of Linux swap ������������������������������������������������������������������������������������������������������������ 122
Thrashing����������������������������������������������������������������������������������������������������������������������������� 123
What is the right amount of swap space?��������������������������������������������������������������������������� 123
Adding more swap space on a non-LVM disk partition ������������������������������������������������������� 126
Table of Contents
viii
Adding swap to an LVM disk environment��������������������������������������������������������������������������� 131
Other swap options with LVM���������������������������������������������������������������������������������������������� 135
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 135
Exercises����������������������������������������������������������������������������������������������������������������������������������� 136
Chapter 6: Regular Expressions ��������������������������������������������������������������������������� 137
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 137
Introducing regular expressions ����������������������������������������������������������������������������������������������� 137
Getting started �������������������������������������������������������������������������������������������������������������������������� 139
The mailing list�������������������������������������������������������������������������������������������������������������������� 139
grep������������������������������������������������������������������������������������������������������������������������������������������� 147
Data flow ����������������������������������������������������������������������������������������������������������������������������� 147
regex building blocks ���������������������������������������������������������������������������������������������������������� 148
Repetition ���������������������������������������������������������������������������������������������������������������������������� 151
Other metacharacters���������������������������������������������������������������������������������������������������������� 152
sed �������������������������������������������������������������������������������������������������������������������������������������������� 154
Other tools that implement regular expressions����������������������������������������������������������������������� 156
Resources ��������������������������������������������������������������������������������������������������������������������������������� 156
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 157
Exercises����������������������������������������������������������������������������������������������������������������������������������� 157
Chapter 7: Printing ����������������������������������������������������������������������������������������������� 159
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 159
Introduction������������������������������������������������������������������������������������������������������������������������������� 160
About printers ��������������������������������������������������������������������������������������������������������������������������� 160
Print languages ������������������������������������������������������������������������������������������������������������������� 161
Printers and Linux ��������������������������������������������������������������������������������������������������������������� 161
CUPS������������������������������������������������������������������������������������������������������������������������������������ 164
Creating the print queue������������������������������������������������������������������������������������������������������ 166
Printing to a PDF file ����������������������������������������������������������������������������������������������������������������� 171
File conversion tools ����������������������������������������������������������������������������������������������������������������� 174
Table of Contents
ix
a2ps������������������������������������������������������������������������������������������������������������������������������������� 175
ps2pdf���������������������������������������������������������������������������������������������������������������������������������� 177
pr����������������������������������������������������������������������������������������������������������������������������������������� 177
ps2ascii ������������������������������������������������������������������������������������������������������������������������������� 178
Operating system–related conversion tools ����������������������������������������������������������������������������� 180
unix2dos ������������������������������������������������������������������������������������������������������������������������������ 181
dos2unix ������������������������������������������������������������������������������������������������������������������������������ 183
unix2mac and mac2unix ����������������������������������������������������������������������������������������������������� 183
Miscellaneous tools ������������������������������������������������������������������������������������������������������������������ 184
lpmove��������������������������������������������������������������������������������������������������������������������������������� 184
wvText and odt2txt �������������������������������������������������������������������������������������������������������������� 187
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 189
Exercises����������������������������������������������������������������������������������������������������������������������������������� 189
Chapter 8: Hardware Detection ���������������������������������������������������������������������������� 191
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 191
Introduction������������������������������������������������������������������������������������������������������������������������������� 191
dmidecode �������������������������������������������������������������������������������������������������������������������������������� 193
lshw ������������������������������������������������������������������������������������������������������������������������������������������ 201
lsusb ����������������������������������������������������������������������������������������������������������������������������������������� 205
usb-devices������������������������������������������������������������������������������������������������������������������������������� 207
lspci ������������������������������������������������������������������������������������������������������������������������������������������ 209
Cleanup������������������������������������������������������������������������������������������������������������������������������������� 212
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 213
Exercises����������������������������������������������������������������������������������������������������������������������������������� 213
Chapter 9: Command-Line Programming ������������������������������������������������������������� 215
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 215
Introduction������������������������������������������������������������������������������������������������������������������������������� 215
Definition of a program������������������������������������������������������������������������������������������������������������� 216
Simple CLI programs����������������������������������������������������������������������������������������������������������������� 217
Table of Contents
x
Some basic syntax �������������������������������������������������������������������������������������������������������������� 217
Output to the display ����������������������������������������������������������������������������������������������������������� 219
Something about variables�������������������������������������������������������������������������������������������������� 221
Control operators ���������������������������������������������������������������������������������������������������������������������� 223
Return codes ����������������������������������������������������������������������������������������������������������������������� 224
The operators ���������������������������������������������������������������������������������������������������������������������� 225
Program flow control ���������������������������������������������������������������������������������������������������������������� 227
true and false ���������������������������������������������������������������������������������������������������������������������� 228
Logical operators����������������������������������������������������������������������������������������������������������������� 229
Grouping program statements �������������������������������������������������������������������������������������������������� 241
Expansions�������������������������������������������������������������������������������������������������������������������������������� 244
Brace expansion������������������������������������������������������������������������������������������������������������������ 245
Tilde expansion�������������������������������������������������������������������������������������������������������������������� 245
Pathname expansion ����������������������������������������������������������������������������������������������������������� 245
Command substitution �������������������������������������������������������������������������������������������������������� 247
Arithmetic expansion����������������������������������������������������������������������������������������������������������� 248
for loops������������������������������������������������������������������������������������������������������������������������������������ 250
Other loops�������������������������������������������������������������������������������������������������������������������������������� 255
while������������������������������������������������������������������������������������������������������������������������������������ 255
until ������������������������������������������������������������������������������������������������������������������������������������� 257
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 258
Exercises����������������������������������������������������������������������������������������������������������������������������������� 259
Chapter 10: Automation with Bash Scripts ���������������������������������������������������������� 261
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 261
Introduction������������������������������������������������������������������������������������������������������������������������������� 262
Why I use shell scripts �������������������������������������������������������������������������������������������������������������� 262
Shell scripts������������������������������������������������������������������������������������������������������������������������� 263
Scripts vs. compiled programs�������������������������������������������������������������������������������������������� 264
Updates������������������������������������������������������������������������������������������������������������������������������������� 265
About updates ��������������������������������������������������������������������������������������������������������������������� 265
Create a list of requirements����������������������������������������������������������������������������������������������� 265
Table of Contents
xi
The CLI program������������������������������������������������������������������������������������������������������������������ 267
Convert the CLI program to a script������������������������������������������������������������������������������������� 267
Add some logic�������������������������������������������������������������������������������������������������������������������� 269
Limit to root������������������������������������������������������������������������������������������������������������������������� 271
Add command-line options ������������������������������������������������������������������������������������������������� 272
Check for updates ��������������������������������������������������������������������������������������������������������������� 274
Is a reboot required? ����������������������������������������������������������������������������������������������������������� 276
Adding a Help function �������������������������������������������������������������������������������������������������������� 279
Finishing the script�������������������������������������������������������������������������������������������������������������� 282
About testing����������������������������������������������������������������������������������������������������������������������������� 283
Testing in production����������������������������������������������������������������������������������������������������������� 284
Fuzzy testing ����������������������������������������������������������������������������������������������������������������������� 285
Testing the script����������������������������������������������������������������������������������������������������������������� 285
Making it better������������������������������������������������������������������������������������������������������������������������� 288
Licensing����������������������������������������������������������������������������������������������������������������������������������� 289
Automated testing��������������������������������������������������������������������������������������������������������������������� 292
Security������������������������������������������������������������������������������������������������������������������������������������� 292
Additional levels of automation������������������������������������������������������������������������������������������������� 293
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 295
Exercises����������������������������������������������������������������������������������������������������������������������������������� 296
Chapter 11: Time and Automation������������������������������������������������������������������������ 297
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 297
Introduction������������������������������������������������������������������������������������������������������������������������������� 297
Keeping time with chrony ��������������������������������������������������������������������������������������������������������� 298
The NTP server hierarchy ���������������������������������������������������������������������������������������������������� 298
NTP choices������������������������������������������������������������������������������������������������������������������������� 299
Chrony structure������������������������������������������������������������������������������������������������������������������ 300
Client configuration ������������������������������������������������������������������������������������������������������������� 300
chronyc as an interactive tool ��������������������������������������������������������������������������������������������� 304
Table of Contents
xii
Using cron for timely automation���������������������������������������������������������������������������������������������� 305
The crond daemon��������������������������������������������������������������������������������������������������������������� 306
crontab �������������������������������������������������������������������������������������������������������������������������������� 306
Other scheduling options ���������������������������������������������������������������������������������������������������������� 312
/etc/cron.d��������������������������������������������������������������������������������������������������������������������������� 312
anacron ������������������������������������������������������������������������������������������������������������������������������� 313
Thoughts about cron����������������������������������������������������������������������������������������������������������������� 315
Scheduling tips�������������������������������������������������������������������������������������������������������������������� 315
Security ������������������������������������������������������������������������������������������������������������������������������� 316
cron resources��������������������������������������������������������������������������������������������������������������������� 316
at����������������������������������������������������������������������������������������������������������������������������������������������� 317
Syntax���������������������������������������������������������������������������������������������������������������������������������� 317
Time specifications�������������������������������������������������������������������������������������������������������������� 317
Security ������������������������������������������������������������������������������������������������������������������������������� 323
Cleanup������������������������������������������������������������������������������������������������������������������������������������� 323
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 323
Exercises����������������������������������������������������������������������������������������������������������������������������������� 324
Chapter 12: Networking���������������������������������������������������������������������������������������� 325
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 325
Introduction������������������������������������������������������������������������������������������������������������������������������� 325
About IPv6 ��������������������������������������������������������������������������������������������������������������������������� 326
Basic networking concepts������������������������������������������������������������������������������������������������������� 326
Definitions ��������������������������������������������������������������������������������������������������������������������������� 326
MAC address ����������������������������������������������������������������������������������������������������������������������� 328
IP address���������������������������������������������������������������������������������������������������������������������������� 331
TCP/IP���������������������������������������������������������������������������������������������������������������������������������������� 334
The TCP/IP network model �������������������������������������������������������������������������������������������������� 334
A simple example ���������������������������������������������������������������������������������������������������������������� 336
Table of Contents
xiii
CIDR – Network notation and configuration������������������������������������������������������������������������������ 338
Network classes ������������������������������������������������������������������������������������������������������������������ 338
Along came a CIDR�������������������������������������������������������������������������������������������������������������� 341
Variable Length Subnet Masking����������������������������������������������������������������������������������������� 344
DHCP client configuration ��������������������������������������������������������������������������������������������������������� 348
NIC naming conventions ����������������������������������������������������������������������������������������������������������� 349
How it works – sort of ��������������������������������������������������������������������������������������������������������� 349
NIC configuration files��������������������������������������������������������������������������������������������������������������� 351
Create an interface configuration file���������������������������������������������������������������������������������� 352
The interface configuration file������������������������������������������������������������������������������������������������� 354
The network file������������������������������������������������������������������������������������������������������������������� 359
The route-<interface> file��������������������������������������������������������������������������������������������������� 359
Other network files�������������������������������������������������������������������������������������������������������������� 360
Network startup ������������������������������������������������������������������������������������������������������������������������ 360
The NetworkManager service ��������������������������������������������������������������������������������������������� 360
Name services �������������������������������������������������������������������������������������������������������������������������� 361
How a name search works�������������������������������������������������������������������������������������������������� 362
Using the /etc/hosts file ������������������������������������������������������������������������������������������������������ 363
Introduction to network routing ������������������������������������������������������������������������������������������������ 367
The routing table ����������������������������������������������������������������������������������������������������������������� 367
iptraf-ng������������������������������������������������������������������������������������������������������������������������������������ 373
Cleanup������������������������������������������������������������������������������������������������������������������������������������� 377
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 377
Exercises����������������������������������������������������������������������������������������������������������������������������������� 378
Chapter 13: systemd��������������������������������������������������������������������������������������������� 379
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 379
Introduction������������������������������������������������������������������������������������������������������������������������������� 379
Controversy������������������������������������������������������������������������������������������������������������������������������� 380
Why I prefer SystemV ���������������������������������������������������������������������������������������������������������� 380
Why I prefer systemd����������������������������������������������������������������������������������������������������������� 381
The real issue ���������������������������������������������������������������������������������������������������������������������� 382
Table of Contents
xiv
systemd suite���������������������������������������������������������������������������������������������������������������������������� 382
Practical structure ��������������������������������������������������������������������������������������������������������������� 383
systemctl����������������������������������������������������������������������������������������������������������������������������������� 384
Service units������������������������������������������������������������������������������������������������������������������������ 388
Mount units ������������������������������������������������������������������������������������������������������������������������� 391
systemd timers ������������������������������������������������������������������������������������������������������������������������� 395
Time specification ��������������������������������������������������������������������������������������������������������������� 396
Timer configuration ������������������������������������������������������������������������������������������������������������� 399
systemd-analyze����������������������������������������������������������������������������������������������������������������������� 403
Journals ������������������������������������������������������������������������������������������������������������������������������������ 404
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 407
References�������������������������������������������������������������������������������������������������������������������������������� 408
Exercises����������������������������������������������������������������������������������������������������������������������������������� 410
Chapter 14: D-Bus and udev��������������������������������������������������������������������������������� 411
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 411
/dev chaos��������������������������������������������������������������������������������������������������������������������������������� 411
About D-Bus ������������������������������������������������������������������������������������������������������������������������ 412
About udev �������������������������������������������������������������������������������������������������������������������������� 412
Naming rules����������������������������������������������������������������������������������������������������������������������������� 415
Making udev work �������������������������������������������������������������������������������������������������������������������� 416
Using Udev for your success ����������������������������������������������������������������������������������������������� 416
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 423
Exercises����������������������������������������������������������������������������������������������������������������������������������� 424
Chapter 15: Logs and Journals����������������������������������������������������������������������������� 425
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 425
Logs are your friend������������������������������������������������������������������������������������������������������������������ 425
SAR ������������������������������������������������������������������������������������������������������������������������������������������� 426
logrotate������������������������������������������������������������������������������������������������������������������������������������ 429
messages���������������������������������������������������������������������������������������������������������������������������������� 433
Table of Contents
xv
Mail logs������������������������������������������������������������������������������������������������������������������������������������ 435
dmesg ��������������������������������������������������������������������������������������������������������������������������������������� 436
secure ��������������������������������������������������������������������������������������������������������������������������������������� 438
Following log files��������������������������������������������������������������������������������������������������������������������� 440
systemd journals����������������������������������������������������������������������������������������������������������������������� 442
logwatch ����������������������������������������������������������������������������������������������������������������������������������� 446
Chapter summary ��������������������������������������������������������������������������������������������������������������������� 456
Exercises����������������������������������������������������������������������������������������������������������������������������������� 456
Chapter 16: Managing Users �������������������������������������������������������������������������������� 459
Objectives ��������������������������������������������������������������������������������������������������������������������������������� 459
Introduction������������������������������������������������������������������������������������������������������������������������������� 459
The root account����������������������������������������������������������������������������������������������������������������������� 460
Your account ����������������������������������������������������������������������������������������������������������������������������� 460
Your home directory ������������������������������������������������������������������������������������������������������������ 461
User accounts and groups �������������������������������������������������������������������������������������������������������� 461
The /etc/passwd file������������������������������������������������������������������������������������������������������������ 463
nologin shells ���������������������������������������������������������������������������������������������������������������������� 467
The /etc/shadow file������������������������������������������������������������������������������������������������������������ 467
The /etc/group file��������������������������������������������������������������������������������������������������������������� 472
The /etc/login.defs file��������������������������������������������������������������������������������������������������������� 472
Account configuration files�������������������������������������������������������������������������������������������������� 472
Password security��������������������������������������������������������������������������������������������������������������������� 473
Password encryption����������������������������������������������������������������������������������������������������������� 474
Generating good passwords������������������������������������������������������������������������������������������������ 476
Password quality ����������������������������������������������������������������������������������������������������������������� 478
Managing user accounts����������������������������������������������������������������������������������������������������������� 480
Creating new accounts�������������������������������������������������������������������������������������������������������� 480
Creating new accounts by editing the files ������������������������������������������������������������������������� 483
Locking the password ��������������������������������������������������������������������������������������������������������� 486
Deleting user accounts�������������������������������������������������������������������������������������������������������� 487
Table of Contents