A Guide to Modern UNIX Systems
Total Page:16
File Type:pdf, Size:1020Kb
A guide to modern UNIX systems Daniël de Kok A guide to modern UNIX systems by Daniël de Kok Copyright © 2007 Daniël de Kok License Redistribution and use in textual and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of this book, or any parts thereof, must retain the above copyright notice, this list of conditions and the following disclaimer. 2. All advertising materials mentioning features or use of this book must display the following acknowledgement: This product includes content written by Daniël de Kok. 3. The name of the author may not be used to endorse or promote products derived from this book without specific prior written permission. THIS BOOK IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS BOOK, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Table of Contents Preface ............................................................................................................................................ xi 1. Introduction ................................................................................................................................... 1 1.1. A short history of UNIX ....................................................................................................... 1 1.2. The current state of UNIX ..................................................................................................... 1 1.3. UNIX philosophy ................................................................................................................. 2 1.4. Free and Open Source software .............................................................................................. 2 2. A whirlwind tour through UNIX ....................................................................................................... 3 2.1. Logging in .......................................................................................................................... 3 2.2. Finding your way around ....................................................................................................... 3 2.3. Working with files ............................................................................................................... 5 2.4. Organizing files ................................................................................................................... 6 2.5. Getting help ........................................................................................................................ 7 2.6. Logging out ......................................................................................................................... 8 3. The shell ....................................................................................................................................... 9 3.1. Introduction ......................................................................................................................... 9 3.2. Executing commands ............................................................................................................ 9 3.3. Moving around ................................................................................................................... 10 3.4. Command history ............................................................................................................... 15 3.5. Completion ........................................................................................................................ 16 3.6. Aliases .............................................................................................................................. 18 3.7. Executing shell commands upon shell invocation ...................................................................... 19 4. Filesystem .................................................................................................................................... 21 4.1. Some theory ...................................................................................................................... 21 4.2. Analyzing files ................................................................................................................... 24 4.3. Working with directories ...................................................................................................... 29 4.4. Managing files and directories .............................................................................................. 30 4.5. Permissions ....................................................................................................................... 32 4.6. Finding files ...................................................................................................................... 41 4.7. Compression and archiving ................................................................................................... 49 5. Text processing ............................................................................................................................. 51 5.1. Simple text manipulation ..................................................................................................... 51 5.2. Regular expressions ............................................................................................................ 66 5.3. grep .................................................................................................................................. 68 6. Process management ...................................................................................................................... 71 6.1. Theory .............................................................................................................................. 71 6.2. Analyzing running processes ................................................................................................. 74 6.3. Managing processes ............................................................................................................ 76 6.4. Job control ........................................................................................................................ 77 Bibliography .................................................................................................................................... 81 v vi vi List of Figures 4.1. The structure of a hard link .......................................................................................................... 23 4.2. The structure of a symbolic link .................................................................................................... 24 6.1. Process states ............................................................................................................................. 72 vii viii viii List of Tables 2.1. Visual indicators for ls -F .............................................................................................................. 5 3.1. Moving by character ................................................................................................................... 11 3.2. Deleting characters ...................................................................................................................... 11 3.3. Swapping characters .................................................................................................................... 12 3.4. Moving by word ......................................................................................................................... 13 3.5. Deleting words ........................................................................................................................... 13 3.6. Modifying words ........................................................................................................................ 14 3.7. Moving through lines .................................................................................................................. 15 3.8. Deleting lines ............................................................................................................................. 15 3.9. Shell history browsing ................................................................................................................. 16 4.1. Common inode fields .................................................................................................................. 21 4.2. Meaning of numbers in the mode octet ........................................................................................... 22 4.3. more command keys ................................................................................................................... 27 4.4. System-specific setfacl flags ......................................................................................................... 38 4.5. Parameters for the '-type' operand .................................................................................................. 43