Table of Contents
Table of Contents
About the Author
About the Technical Reviewer
Preface
Part 1: Preparing for Part I
Chapter 1: Editing Text with Vim and Joe
1.1 A Brief History of Unix Text Editors
1.2 Important Terms
1.2.1 Line
1.2.2 Regular Expressions: What You Need To Know Right Now
1.2.3 Remaining Terms of Endearment
1.3 Vi IMproved (Vim)
1.3.1 Moving Around in the Buffer
1.3.2 Registers and Clipboard Integration
1.3.3 Marks
1.3.4 Find and Replace
1.3.5 Visual Selection Modes
1.3.6 Recording and Playing Macros
1.3.7 Vim Utilities
1.3.8 Vim Configuration
1.3.9 Vim Abbreviations and Auto-Completion Framework
1.3.10 Installing Vim
1.4 Joe’s Own Editor (Joe)
1.4.1 Installing Joe
1.5 Summary
Chapter 2: Essential Unix Commands and Terminology
2.1 Kernel, Shell, and Filesystem
2.2 Files and Special Files
2.2.1 The Null Device
2.2.2 Standard Input
2.2.3 Standard Output
2.2.4 Standard Error
2.2.5 The Pipe
2.2.6 Console
2.3 Essential Unix Commands
2.3.1 echo <string>
2.3.2 cd <path>
2.3.3 pwd
2.3.4 ls <path>
2.3.5 mkdir <path>
2.3.6 cp <source> <destination>
2.3.7 mv <source> <destination>
2.3.8 rm <path>
2.3.9 ln [-s] <path> <additional>
2.3.10 cat <file>
2.3.11 test <condition>
2.3.12 expr
2.3.13 dd
2.3.14 grep <regex> [<file>]
2.3.15 awk [<file>]
2.3.16 sed [<file>]
2.3.17 file <path>
2.3.18 find
2.3.19 updatedb
2.3.20 locate <name>
2.3.21 basename <string>
2.3.22 dirname <string>
2.3.23 realpath <path>
2.3.24 head [<file>]
2.3.25 tail [<file>]
2.3.26 rev [<file>]
2.3.27 cut [<file>]
2.3.28 tr
2.3.29 read <arg>
2.3.30 date
2.3.31 type <executable>
2.3.32 wc [<file>]
2.3.33 less [<file>]
2.3.34 man <topic>
2.3.35 set
2.3.36 uname
2.3.37 who
2.3.38 cmp <file1> <file2>
2.3.39 diff <file1> <file2>
2.3.40 ps
2.3.41 kill [<sig>] <pid>
2.3.42 sleep <n>
2.3.43 sort [<file>]
2.3.44 uniq [<file>]
2.3.45 chmod <mode> <file>
2.3.46 chown <user> <file>
2.3.47 chsh [<user>]
2.3.48 passwd [<user>]
2.3.49 touch <file>
2.3.50 tar
2.3.51 gzip
2.3.52 xz
2.3.53 source <file>
2.3.54 wget
2.3.55 md5[sum] <file>
2.3.56 sha256[sum] <file>
2.4 Summary
Chapter 3: Bourne Shell Scripting
3.1 Inside Our First Shell Script
3.2 Variable Assignment
3.3 Arithmetic and Boolean Operations
3.4 Command Chaining and Grouping
3.5 Meta-Character Expansion
3.6 Quoting: Single, Double, and Back
3.7 Setting the Shell Prompt
3.8 Dealing with Whitespace in Filenames
3.9 Shell Functions
3.10 Special Variables
3.11 Branching and Looping
3.12 The shift Command
3.13 Sourcing, Aliasing, and Exporting
3.14 Putting It All Together
3.15 Summary
Part 2: Preparing for Part II
Chapter 4: PC Hardware for Unix
4.1 A Shopping List
4.2 Preparatory Notes
4.3 CPU (Central Processing Unit)
4.4 System Board/Motherboard
4.5 RAM (Random Access Memory)
4.6 Hard Disk
4.7 SMPS (Switched Mode Power Supply)
4.8 Cabinet
4.9 Graphics Card
4.10 Optical Drive (CD/DVD Reader and Writer)
4.11 CPU Cooler
4.12 Printer/Scanner
4.12.1 Buying an HP Printer
4.12.2 Buying an Epson Printer
4.13 Summary
Chapter 5: Installing and Configuring FreeBSD/Linux
5.1 Disk Partitioning
5.1.1 MBR (Master Boot Record)
5.1.2 GPT (GUID Partition Table)
5.2 Do We Have Enough Disk Space?
5.3 The Default Partitioning Scheme
5.4 Preparing the Computer’s CMOS for Unix
5.5 Downloading and Burning Installation Media
5.6 Our Example Hard Disk
5.7 Installing FreeBSD
5.8 Installing and Configuring Linux
5.9 Post-Install Configuration of FreeBSD
5.9.1 Networking
5.9.2 Software Packaging Subsystem
5.9.3 A Friendlier Shell
5.9.4 X Server
5.9.5 NVIDIA Graphics Driver Addition
5.9.6 NVIDIA and ATI Radeon Graphics Configuration
5.9.7 User Accounts
5.9.8 Graphical Desktop Environment
5.9.9 Making Things Easier: A Simpler Way to Configure FreeBSD
5.10 Dual-Booting FreeBSD and Linux on a GPT Disk
5.11 Summary
Chapter 6: Basic System Administration
6.1 Being Root
6.2 Local Filesystems
6.3 Partition Management
6.4 Console Configuration
6.5 Internet Connectivity
6.6 Sound Configuration
6.7 X Configuration
6.8 Running X Applications as Root
6.9 Finding Local Files Quickly
6.10 Configuring the Printer
6.11 Using the Scanner
6.12 Using an APC Powerchute UPS to Shut the System Down
6.13 Building Stuff from Sources
6.14 Unix Virtual Filesystems
6.15 Additional Commands to Administer Your Desktop
6.15.1 df
6.15.2 du
6.15.3 at
6.15.4 cdrecord
6.15.5 Loop Device Configuration
6.15.6 smtp-cli
6.15.7 rsync
6.16 Mitigating the Need for Backups
6.17 Summary
Chapter 7: The Best of the Graphical Unix
7.1 X Is a Client-Server System
7.2 Desktop Environments
7.3 Window Managers
7.4 Starting X and the Desktop Environment
7.5 Applications in the Desktop Environment
7.5.1 Terminal Emulators
7.5.2 Web Browsers
7.5.3 Email Clients
7.5.4 Accessing and Downloading Remote Data
7.5.5 Playing Multimedia Content
7.5.5.1 The mplayer Cult
7.5.5.2 VideoLAN/VLC
7.5.5.3 Xine
7.5.6 Paint Programs
7.5.7 LibreOffice: The New and Better Office
7.5.8 PDF Viewers
7.5.9 PDF Creation
7.5.10 CD/DVD Writing Frontends
7.5.11 Internet Messaging and Chat Clients
7.5.12 Multimedia Editing Software
7.5.13 Fun Stuff: Games and Blogging
7.5.14 The Question of a Graphical Integrated Development Environment
7.6 Summary
Chapter 8: Emulation Layers: Wine and Linuxulator
8.1 Wine HQ: Attacking Redmond
8.2 Installing Wine
8.3 The Filesystem Hierarchy of Wine
8.4 Running Windows Applications Under Wine
8.5 Running Pinta as a Windows Application
8.6 Maintaining Your Wine Environment
8.7 Wine Patches
8.8 Version Mimicking Under Wine
8.9 Wine Libraries (DLLs)
8.10 Tweaking Wine Still Further
8.11 Wine Uses a Client-Server Model Too
8.12 Graphical Tools for Wine Administration
8.13 Developing Applications for Wine
8.14 The 64-Bit Mess
8.15 Yet Another Imitation Game: Linuxulator
8.15.1 Using c6 Linuxulator
8.15.2 Using c7 Linuxulator
8.15.3 Installing Linux ABI Applications via rpm
8.16 Summary
Chapter 9: Virtualization: The New Buzzword
9.1 What Is Virtualization (And Why Is It Important)?
9.2 Storage for Virtual Machines
9.3 Running an Anonymous FTP Server Under FreeBSD/Linux
9.4 VirtualBox
9.4.1 Installing VirtualBox
9.4.1.1 Installing Under FreeBSD
9.4.1.2 Installing Under Ubuntu
9.4.1.3 Installing Under Arch Linux
9.4.2 Hosting Your First VirtualBox Virtual Machine
9.4.3 Exchanging Files with the VirtualBox Host
9.4.4 VirtualBox Extensions
9.5 KVM
9.6 BHyVe
9.7 Summary
Part 3: Preparing for Part III
Chapter 10: Advanced Techniques in Shell Scripting
10.1 The here-doc Tool
10.2 Variable Type Modifiers: Readonly/Local
10.3 Bit-Wise Operations
10.4 Trapping Signals
10.5 Mixed Quotes
10.6 Recursion
10.7 Special Shell Variables: LINENO and IFS
10.8 The Magic of eval
10.9 Non-POSIX Scripting
10.10 Scripting with ncurses
10.10.1 Message Box
10.10.2 YesNo box
10.10.3 Input Box
10.10.4 Range Box
10.10.5 Text Box
10.10.6 Program Box
10.10.7 Menu Box
10.10.8 Radio List
10.10.9 Progress Gauge
10.10.10 Check List
10.10.11 Time Box
10.10.12 Calendar Box
10.10.13 File Selection Box
10.10.14 And There Are Many More
10.11 Scripting with GTK
10.12 Summary
Chapter 11: Unix Programming with C and Vala
11.1 Systems Programming with C
11.1.1 The C Compilation Process
11.1.2 Data Types in C
11.1.3 int
11.1.4 char
11.1.5 bool
11.1.6 Pointers
11.1.7 Arrays
11.1.8 Differentiating Between Stack and Heap
11.1.9 Strings in C
11.1.10 Signature of main()
11.1.11 Branching and Looping
11.1.12 Arithmetic and Logical Operations
11.1.13 Functions
11.1.14 Declarations and Definitions
11.1.15 Structs
11.1.16 Preprocessor
11.1.17 Variable Argument Lists
11.1.18 Input/Output
11.1.19 Using System Calls for I/O
11.1.20 Multithreading with pthreads
11.1.21 Socket Programming
11.1.22 Addressing the Makefile
11.2 Graphical Application Development with Vala
11.2.1 The Bare Essentials of OOP
11.2.2 Charter of OO Terminology
11.2.3 Benefits and Drawbacks of OO Programming
11.2.4 The World of Vala
11.2.5 Vala Documentation
11.2.6 The BMI Tool Written in Vala
11.2.7 Vala Is Not Just GUI Development!
11.3 Summary
Appendix
The Last Frontier
A.1 Solution to the Difficult Step in Chapter 1
A.2 Sources for the Shell Script tcase from Chapter 3
A.3 Sources for the Shell Script extract.sh from Chapter 3
A.4 Setting Up a Swap Partition Shared by FreeBSD and Linux from Chapter 5
A.5 Sources for halt.c from Chapter 8
A.6 GNUmakefile for Creating an Executable from Chapter 11
Index