Linux Essentials//The LPI Introductory Programme
Total Page:16
File Type:pdf, Size:1020Kb
Linux Essentials The LPI Introductory Programme Linup Front GmbH Postfach 10 01 21 64201 Darmstadt Germany ⋅ ⋅ ⋅ Telefon +49(0) 6151 9067 0 Telefax +49(0) 6151 9067 299 www.linupfront.de ⋅ ⋅ Linup Front GmbH is a leading supplier of high-quality training materials for Linux and Open Source topics, at reason- able prices – for self-study, school, higher and continuing education and professional training. Please visit http://shop.linupfront.com/ for details and pricing, or contact us with questions or suggestions. All representations and information contained in this document have been com- piled to the best of our knowledge and carefully tested. However, mistakes cannot be ruled out completely. The authors and Linup Front GmbH assume no respon- sibility or liability resulting in any way from the use of this material or parts of it or from any violation of the rights of third parties. Reproduction of trade marks, service marks and similar monikers in this docu- ment, even if not specially marked, does not imply the stipulation that these may be freely usable according to trade mark protection laws. All trade marks are used without a warranty of free usability and may be registered trade marks of third parties. This document is published under the “Creative Commons-BY-NC-ND 3.0 Un- ported” licence. You may copy and distribute it and make it publically available as long as the following conditions are met: Attribution You must make clear that this document is a product of Linup Front GmbH. No commercial use You may not use this document for commercial purposes (contact us if you want to use this document commercially). No derivatives You may not alter, transform, or build upon this document (con- tact us if necessary). The full legal license grant can be found at http://creativecommons.org/licenses/by- nc-nd/3.0/legalcode Authors: Tobias Elsner, Thomas Erker, Anselm Lingnau Technical Editor: Anselm Lingnau [email protected] ⟨ ⟩ Typeset in Palatino, Optima and DejaVu Sans Mono Register this manual on-line via the QR code on the left or http://shop.linupfront. com/register/hnINuUQTazcf7HFRIM80of/ for updates and interesting special offers. Contents 1 Computers, Software and Operating Systems 13 1.1 What Is A Computer, Anyway? . 14 1.2 Components Of A Computer . 15 1.3 Software . 19 1.4 The Most Important Operating Systems. 20 1.4.1 Windows And OS X . 20 1.4.2 Linux . 21 1.4.3 More Differences And Similarities. 22 1.5 Summary. 22 2 Linux and Free Software 25 2.1 Linux: A Success Story . 26 2.2 Free Or Open Source? . 28 2.2.1 Copyright And “Free Software” . 28 2.2.2 Licences . 31 2.2.3 The GPL . 32 2.2.4 Other Licences . 35 2.3 Important Free Software . 37 2.3.1 Overview . 37 2.3.2 Office and Productivity Tools . 37 2.3.3 Graphics and Multimedia Tools . 38 2.3.4 Internet Services . 39 2.3.5 Infrastructure Software. 39 2.3.6 Programming Languages and Development . 39 2.4 Important Linux Distributions . 40 2.4.1 Overview . 40 2.4.2 Red Hat . 40 2.4.3 SUSE . 41 2.4.4 Debian . 42 2.4.5 Ubuntu . 43 2.4.6 Others . 44 2.4.7 Differences and Similarities . 44 3 First Steps with Linux 47 3.1 Logging In and Out . 48 3.2 Desktop Environment and Browser . 49 3.2.1 Graphical Desktop Environments . 49 3.2.2 Browsers . 51 3.2.3 Terminals and Shells. 51 3.3 Creating and Modifying Text Files . 51 4 Who’s Afraid Of The Big Bad Shell? 57 4.1 Why? . 58 4.1.1 What Is The Shell? . 58 Copyright © 2012 Linup Front GmbH 4 Contents 4.2 Commands . 59 4.2.1 Why Commands?. 59 4.2.2 Command Structure. 60 4.2.3 Command Types . 61 4.2.4 Even More Rules . 61 5 Getting Help 63 5.1 Self-Help . 64 5.2 The help Command and the --help Option . 64 5.3 The On-Line Manual . 64 5.3.1 Overview . 64 5.3.2 Structure . 65 5.3.3 Chapters . 66 5.3.4 Displaying Manual Pages . 66 5.4 Info Pages . 67 5.5 HOWTOs. 68 5.6 Further Information Sources . 68 6 Files: Care and Feeding 71 6.1 File and Path Names . 72 6.1.1 File Names . 72 6.1.2 Directories . 73 6.1.3 Absolute and Relative Path Names . 74 6.2 Directory Commands . 75 6.2.1 The Current Directory: cd & Co. 75 6.2.2 Listing Files and Directories—ls . 76 6.2.3 Creating and Deleting Directories: mkdir and rmdir . 77 6.3 File Search Patterns . 78 6.3.1 Simple Search Patterns . 78 6.3.2 Character Classes. 80 6.3.3 Braces . 81 6.4 Handling Files . 82 6.4.1 Copying, Moving and Deleting—cp and Friends. 82 6.4.2 Linking Files—ln and ln -s . 84 6.4.3 Displaying File Content—more and less . 87 6.4.4 Searching Files—find . 87 6.4.5 Finding Files Quickly—locate and slocate . 91 7 Regular Expressions 95 7.1 Regular Expressions: The Basics . 96 7.1.1 Regular Expressions: Extras . 96 7.2 Searching Files for Text—grep . 97 8 Standard I/O and Filter Commands 101 8.1 I/O Redirection and Command Pipelines . 102 8.1.1 Standard Channels . 102 8.1.2 Redirecting Standard Channels . 103 8.1.3 Command Pipelines . 106 8.2 Filter Commands . 107 8.3 Reading and Writing Files . 108 8.3.1 Outputting and Concatenating Text Files—cat . 108 8.3.2 Beginning and End—head and tail . 108 8.4 Data Management . 109 8.4.1 Sorted Files—sort and uniq . 109 8.4.2 Columns and Fields—cut, paste etc. 114 9 More About The Shell 119 Copyright © 2012 Linup Front GmbH 5 9.1 Simple Commands: sleep, echo, and date . 120 9.2 Shell Variables and The Environment. 121 9.3 Command Types – Reloaded . 123 9.4 The Shell As A Convenient Tool . 124 9.5 Commands From A File . 127 9.6 The Shell As A Programming Language. 128 10 The File System 133 10.1 Terms . 134 10.2 File Types. 134 10.3 The Linux Directory Tree . 135 10.4 Directory Tree and File Systems. 143 11 Archiving and Compressing Files 145 11.1 Archival and Compression . 146 11.2 Archiving Files Using tar . 147 11.3 Compressing Files with gzip . 150 11.4 Compressing Files with bzip2 . 151 11.5 Archiving and Compressing Files Using zip and unzip . 152 12 Introduction to System Administration 157 12.1 System Administration Basics . 158 12.2 System Configuration . 159 12.3 Processes . 160 12.4 Package Management . 165 13 User Administration 169 13.1 Basics . 170 13.1.1 Why Users? . 170 13.1.2 Users and Groups . 171 13.1.3 People and Pseudo-Users . 173 13.2 User and Group Information. 173 13.2.1 The /etc/passwd File . 173 13.2.2 The /etc/shadow File . 176 13.2.3 The /etc/group File . 178 13.2.4 The /etc/gshadow File . 179 13.3 Managing User Accounts and Group Information . 180 13.3.1 Creating User Accounts . 180 13.3.2 The passwd Command . 182 13.3.3 Deleting User Accounts . 183 13.3.4 Changing User Accounts and Group Assignment . 184 13.3.5 Changing User Information Directly—vipw . 184 13.3.6 Creating, Changing and Deleting Groups . 184 14 Access Control 187 14.1 The Linux Access Control System . 188 14.2 Access Control For Files And Directories . 188 14.2.1 The Basics . 188 14.2.2 Inspecting and Changing Access Permissions. 189 14.2.3 Specifying File Owners and Groups—chown and chgrp . 190 14.3 Process Ownership . 191 14.4 Special Permissions for Executable Files . 191 14.5 Special Permissions for Directories . 192 Copyright © 2012 Linup Front GmbH 6 Contents 15 Linux Networking 197 15.1 Networking Basics . 198 15.1.1 Introduction and Protocols . 198 15.1.2 Addressing and Routing . 199 15.1.3 Names and the DNS. 201 15.1.4 IPv6 . 202 15.2 Linux As A Networking Client . 203 15.2.1 Requirements . 203 15.2.2 Troubleshooting . 204 A Sample Solutions 211 B Example Files 223 C Linux Essentials Certification 227 C.1 Exam Objective Overview . 227 C.2 Exam Objectives For Linux Essentials . 228 D Command Index 235 Index 239 Copyright © 2012 Linup Front GmbH List of Tables 2.1 Comparison of the most important Linux distributions (as of Febru- ary, 2012) . 45 5.1 Manual page sections . 65 5.2 Manual Page Topics . 66 6.1 Some file type designations in ls .................... 76 6.2 Some ls options . 76 6.3 Options for cp ............................... 82 6.4 Keyboard commands for more ...................... 87 6.5 Keyboard commands for less ...................... 88 6.6 Test conditions for find .......................... 88 6.7 Logical operators for find ......................... 89 6.6 Test conditions for find .......................... 89 7.1 Regular expression support . ..