Introduction xxix Part I: Introducing Linux 2 Chapter 1 Distributions and Key Components 4 Introducing Linux 4 Linux Distributions 5 Shells 6 GUI Software 7 Installing Linux 7 Which Distro? 8 Native or Virtual Machine? 9 Installing a Distro 10 Summary 12 Key Terms 12 Review Questions 12 Chapter 2 Working on the Command Line 14 File Management 14 The Linux Filesystem 14 Command Execution 16 The pwd Command 16 The cd Command 16 The ls Command 17 File Globbing 18 The file Command 19 The less Command 19 The head Command 19 The tail Command 20 The mdkir Command 20 The cp Command 20 The mv Command 21 The rm Command 21 The rmdir Command 22 The touch Command 22 Shell Features 22 Shell Variables 22 Initialization Files 27 Alias 28 Command History 29 Redirecting Input and Output 30 Advanced Commands 33 The find Command 33 Regular Expressions 35 The grep Command 36 The sed Command 37 Compression Commands 38 Summary 40 Key Terms 40 Review Questions 41 Chapter 3 Getting Help 42 Man Pages 42 Man Page Components 42 Man Page Sections 43 Man Page Locations 46 Command Help Options 46 The help Command 46 The info Command 47 The /usr/share/doc Directory 48 Internet Resources 49 Summary 50 Key terms 50 Review Questions 51 Chapter 4 Editing Files 52 The vi Editor 52 What Is vim? 53 Essential vi Commands 54 Use Basic vi Modes 54 Entering the Insert Mode 55 Movement Commands 56 Repeater Modifiers 57 Undoing 57 Copying, Deleting, and Pasting 58 Finding Text 59 Find and Replace 60 Saving and Quitting 61 Expand Your vi Knowledge 62 Additional Editors 63 Emacs 63 gedit and kwrite 65 nano and joe 65 lime and bluefish 65 Summary 66 Key Terms 66 Review Questions 66 Chapter 5 When Things Go Wrong 68 The Science of Troubleshooting 68 Step 1: Gathering Information 69 Step 2: Determine the Likely Cause 70 Step 3: Document Your Plan of Attack (POA) 71 Step 4: Perform the Actions 71 Steps 5 and 6: Is the Problem Solved? 71 Step 7: Are There Other Problems? 71 Step 8: Store the Documentation 72 Step 9: Prevent Future Problems 72 Notifying Users 72 Pre- and Post-login Messages 72 Broadcasting Messages 77 Summary 79 Review Questions 79 Part II: User and Group Accounts 80 Chapter 6 Managing Group Accounts 82 What Are Groups Used For? 82 Primary versus Secondary Groups 82 The /etc/group File 84 Special Groups 85 User Private Groups 86 The /etc/gshadow File 88 Managing Groups 90 Creating Groups 90 Modifying Groups 91 Deleting Groups 91 Adding Users to Groups 92 Group Administrators 93 Summary 93 Key Terms 93 Review Questions 94 Chapter 7 Managing User Accounts 96 The Importance of User Accounts 96 User Account Information 96 The /etc/passwd File 97 Special Users 98 The /etc/shadow File 99 Managing Users 102 Creating Users 102 Modifying Users 105 Managing GECOS 105 Deleting Users 107 Restricted Shell Accounts 107 Network-Based User Accounts 108 Using su and sudo 108 Restricting User Accounts 111 Summary 116 Key Terms 116 Review Questions 117 Chapter 8 Develop an Account Security Policy 118 Introducing Kali Linux 118 Security Principles 119 Creating a Security Policy 120 Securing Accounts 120 Physical Security 120 Educating Users 121 Account Security 121 Security Tools 124 The john and Johnny Tools 124 The hydra tool 125 Summary 126 Review Questions 126 Part III File and Data Storage 128 Chapter 9 File Permissions 130 Standard Permissions 130 Viewing Permissions 130 Files Versus Directories 131 Changing Permissions 131 Default Permissions 132 Special Permissions 134 SUID 134 SGID 136 Sticky Bit 138 Access Control Lists (ACLs) 139 The mask Value 141 Default ACLs 141 Changing Ownership 143 chown 143 chgrp 144 File Attributes 145 Introduction to SELinux 146 Users Create Security Holes 146 Daemon Processes Create Security Holes 146 SELinux Essentials 147 Summary 149 Key Terms 150 Review Questions 150 Chapter 10 Manage Local Storage: Essentials 152 Filesystem Essentials 152 Partitions 152 Filesystems 153 Why So Many Partitions/Filesystems? 154 Which Partitions/Filesystems Should Be Created? 155 Filesystem Types 155 Managing Partitions 156 Ext-Based Filesystem Tools 161 Xfs-Based Filesystem Tools 166 Additional Filesystem Tools 170 du 170 df 170 Mounting Filesystems 170 The umount Command 171 The mount Command 171 Mounting Filesystems Manually 173 Problems Unmounting Filesystems 174 Mounting Filesystems Automatically 175 Device Descriptors 176 Mount Options 177 Mounting Removable Media 179 Swap Space 179 Creating Swap Devices 180 Summary 181 Key Terms 181 Review Questions 181 Chapter 11 Manage Local Storage: Advanced Features 184 Encrypted Filesystems 184 Managing autofs 186 Logical Volume Manager 189 Logical Volume Manager Concepts 190 LVM Essentials 192 Using Logical Volumes and Additional LVM Commands 197 Resizing Logical Volumes 201 LVM Snapshots 204 Disk Quotas 206 Setting Up a Disk Quota for a Filesystem 207 Editing, Checking, and Generating User Quota Reports 207 Hard and Soft Links 210 Why Use Links? 211 Creating Links 211 Displaying Linked Files 212 Summary 212 Key Terms 212 Review Questions 212 Chapter 12 Manage Network Storage 214 Samba 214 SAMBA Configuration 215 SAMBA Server 218 SAMBA Accounts 220 Accessing SAMBA Servers 221 Network File System 223 Configuring an NFS Server 224 Configuring an NFS Client 229 iSCSI 230 Summary 236 Key Terms 236 Review Questions 236 Chapter 13 Develop a Storage Security Policy 240 Developing the Plan 240 Backing Up Data 241 Creating a Backup Strategy 241 Standard Backup Utilities 246 Third-party Backup Utilities 250 Summary 250 Key Terms 251 Review Questions 251 Part IV: Automation 252 Chapter 14 crontab and at 254 Using crontab 254 Configure User Access to the cron Service 256 /etc/crontab 258 /etc/anacrontab 260 Using at 261 atq 261 atrm 262 Configure User Access to at Services 262 Summary 263 Key Terms 263 Review Questions 263 Chapter 15 Scripting 264 Linux Programming 264 BASH Shell Scripting 265 Perl Scripting 265 Python Scripting 266 Basics of BASH Scripting 268 Conditional Expressions 269 Flow Control Statements 271 The while Loop 272 The for Loop 272 Loop Control 272 The case Statement 272 User Interaction 273 Using Command Substitution 274 Additional Information 274 Summary 274 Key Terms 274 Review Questions 275 Chapter 16 Common Automation Tasks 276 Exploring Scripts that Already Exist on Your System 276 The /etc/cron.* Directories 276 Repositories 279 Creating Your Own Automation Scripts 280 Summary 281 Key Terms 281 Review Questions 281 Chapter 17 Develop an Automation Security Policy 282 Securing crontab and at 282 Securing BASH Scripts 283 Access to Scripts 283 Script Contents 284 Dealing with Data 284 Shell Settings 284 Shell Style 285 Summary 285 Review Questions 285 Part V: Networking 286 Chapter 18 Networking Basics 288 Network Terminology 288 IPv4 Versus IPv6 290 IPv4 Addresses 292 Determining a Network Address from an IP Address and Subnet 293 Private IP Addresses 294 Common Protocol Suites 294 Network Ports 295 Summary 297 Key Terms 297 Review Questions 297 Chapter 19 Network Configuration 298 Ethernet Network Interfaces 298 Displaying Ethernet Port Configurations 299 Changing Ethernet Port Settings 300 Network Configuration Tools 301 The arp Command 302 The route Command 303 The ip Command 304 The hostname Command 305 The host Command 305 The dig Command 306 The netstat Command 307 Persistent Network Configurations 307 The /etc/hostname File (Universal) 307 The /etc/hosts File (Universal) 307 The /etc/resolv.conf File (Universal) 308 The /etc/nsswitch.conf File (Universal) 308 The /etc/sysctl.conf File (Universal) 309 The /etc/sysconfig/network File (Red Hat) 310 The /etc/sysconfig/network-scripts/ifcfg-interface-name Files (Red Hat) 310 The /etc/network/interfaces File (Debian) 311 Network Troubleshooting Commands 311 The ping Command 311 The traceroute Command 312 The netcat Command 313 Access to Wireless Networks 314 The iwconfig Command 314 The iwlist Command 315 Summary 316 Key Terms 316 Review Questions 317 Chapter 20 Network Service Configura.
Linux Essentials for Cybersecurity