Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
How Linux Works: What Every Superuser Should Know
Praise for the First Edition of How Linux Works
Preface
Who Should Read This Book?
Prerequisites
How to Read This Book
A Hands-On Approach
How This Book is Organized
What’s New in the Second Edition?
A Note on Terminology
Acknowledgments
1. The Big Picture
1.1 Levels and Layers of Abstraction in a Linux System
1.2 Hardware: Understanding Main Memory
1.3 The Kernel
1.3.1 Process Management
1.3.2 Memory Management
1.3.3 Device Drivers and Management
1.3.4 System Calls and Support
1.4 User Space
1.5 Users
1.6 Looking Forward
2. Basic Commands and Directory Hierarchy
2.1 The Bourne Shell: /bin/sh
2.2 Using the Shell
2.2.1 The Shell Window
2.2.2 cat
2.2.3 Standard Input and Standard Output
2.3 Basic Commands
2.3.1 ls
2.3.2 cp
2.3.3 mv
2.3.4 touch
2.3.5 rm
2.3.6 echo
2.4 Navigating Directories
2.4.1 cd
2.4.2 mkdir
2.4.3 rmdir
2.4.4 Shell Globbing (Wildcards)
2.5 Intermediate Commands
2.5.1 grep
2.5.2 less
2.5.3 pwd
2.5.4 diff
2.5.5 file
2.5.6 find and locate
2.5.7 head and tail
2.5.8 sort
2.6 Changing Your Password and Shell
2.7 Dot Files
2.8 Environment and Shell Variables
2.9 The Command Path
2.10 Special Characters
2.11 Command-Line Editing
2.12 Text Editors
2.13 Getting Online Help
2.14 Shell Input and Output
2.14.1 Standard Error
2.14.2 Standard Input Redirection
2.15 Understanding Error Messages
2.15.1 Anatomy of a UNIX Error Message
2.15.2 Common Errors
No such file or directory
File exists
Not a directory, Is a directory
No space left on device
Permission denied
Operation not permitted
Segmentation fault, Bus error
2.16 Listing and Manipulating Processes
2.16.1 Command Options
2.16.2 Killing Processes
2.16.3 Job Control
2.16.4 Background Processes
2.17 File Modes and Permissions
2.17.1 Modifying Permissions
2.17.2 Symbolic Links
2.17.3 Creating Symbolic Links
2.18 Archiving and Compressing Files
2.18.1 gzip
2.18.2 tar
Unpacking tar files
Table-of-Contents Mode
2.18.3 Compressed Archives (.tar.gz)
2.18.4 zcat
2.18.5 Other Compression Utilities
2.19 Linux Directory Hierarchy Essentials
2.19.1 Other Root Subdirectories
2.19.2 The /usr Directory
2.19.3 Kernel Location
2.20 Running Commands as the Superuser
2.20.1 sudo
2.20.2 /etc/sudoers
2.21 Looking Forward
3. Devices
3.1 Device Files
3.2 The sysfs Device Path
3.3 dd and Devices
3.4 Device Name Summary
3.4.1 Hard Disks: /dev/sd*
3.4.2 CD and DVD Drives: /dev/sr*
3.4.3 PATA Hard Disks: /dev/hd*
3.4.4 Terminals: /dev/tty*, /dev/pts/*, and /dev/tty
Display Modes and Virtual Consoles
3.4.5 Serial Ports: /dev/ttyS*
3.4.6 Parallel Ports: /dev/lp0 and /dev/lp1
3.4.7 Audio Devices: /dev/snd/*, /dev/dsp, /dev/audio, and More
3.4.8 Creating Device Files
3.5 udev
3.5.1 devtmpfs
3.5.2 udevd Operation and Configuration
3.5.3 udevadm
3.5.4 Monitoring Devices
3.6 In-Depth: SCSI and the Linux Kernel
3.6.1 USB Storage and SCSI
3.6.2 SCSI and ATA
3.6.3 Generic SCSI Devices
3.6.4 Multiple Access Methods for a Single Device
4. Disks and Filesystems
4.1 Partitioning Disk Devices
4.1.1 Viewing a Partition Table
Initial Kernel Read
4.1.2 Changing Partition Tables
4.1.3 Disk and Partition Geometry
4.1.4 Solid-State Disks (SSDs)
4.2 Filesystems
4.2.1 Filesystem Types
4.2.2 Creating a Filesystem
4.2.3 Mounting a Filesystem
4.2.4 Filesystem UUID
4.2.5 Disk Buffering, Caching, and Filesystems
4.2.6 Filesystem Mount Options
Short Options
Long Options
4.2.7 Remounting a Filesystem
4.2.8 The /etc/fstab Filesystem Table
4.2.9 Alternatives to /etc/fstab
4.2.10 Filesystem Capacity
4.2.11 Checking and Repairing Filesystems
Checking ext3 and ext4 Filesystems
The Worst Case
4.2.12 Special-Purpose Filesystems
4.3 swap space
4.3.1 Using a Disk Partition as Swap Space
4.3.2 Using a File as Swap Space
4.3.3 How Much Swap Do You Need?
4.4 Looking Forward: Disks and User Space
4.5 Inside a Traditional Filesystem
4.5.1 Viewing Inode Details
4.5.2 Working with Filesystems in User Space
4.5.3 The Evolution of Filesystems
5. How the Linux Kernel Boots
5.1 Startup Messages
5.2 Kernel Initialization and Boot Options
5.3 Kernel Parameters
5.4 Boot Loaders
5.4.1 Boot Loader Tasks
5.4.2 Boot Loader Overview
5.5 GRUB Introduction
5.5.1 Exploring Devices and Partitions with the GRUB Command Line
Listing Devices
File Navigation
5.5.2 GRUB Configuration
Reviewing Grub.cfg
Generating a New Configuration File
5.5.3 GRUB Installation
Installing GRUB on Your System
Installing GRUB on an External Storage Device
Installing GRUB with UEFI
5.6 UEFI Secure Boot Problems
5.7 Chainloading Other Operating Systems
5.8 Boot Loader Details
5.8.1 MBR Boot
5.8.2 UEFI Boot
5.8.3 How GRUB Works
6. How User Space Starts
6.1 Introduction to init
6.2 System V Runlevels
6.3 Identifying Your init
6.4 systemd
6.4.1 Units and Unit Types
6.4.2 systemd Dependencies
Ordering
Conditional Dependencies
6.4.3 systemd Configuration
Unit Files
Enabling Units and the [Install] Section
Variables and Specifiers
6.4.4 systemd Operation
6.4.5 Adding Units to systemd
Removing Units
6.4.6 systemd Process Tracking and Synchronization
6.4.7 systemd On-Demand and Resource-Parallelized Startup
Boot Optimization with Auxiliary Units
An Example Socket Unit and Service
Instances and Handoff
6.4.8 systemd System V Compatibility
6.4.9 systemd Auxiliary Programs
6.5 Upstart
6.5.1 Upstart Initialization Procedure
6.5.2 Upstart Jobs
Viewing Jobs
Job State Transitions
6.5.3 Upstart Configuration
A Service Job: tty1
Process Tracking and the Upstart expect Stanza
6.5.4 Upstart Operation
6.5.5 Upstart Logs
6.5.6 Upstart Runlevels and System V Compatibility
6.6 System V init
respawn
ctrlaltdel
sysinit
6.6.1 System V init: Startup Command Sequence
6.6.2 The System V init Link Farm
Starting and Stopping Services
Modifying the Boot Sequence
6.6.3 run-parts
6.6.4 Controlling System V init
6.7 Shutting Down Your System
6.8 The Initial RAM Filesystem
6.9 Emergency Booting and Single-User Mode
7. System Configuration: Logging, System Time, Batch Jobs, and Users
7.1 The Structure of /etc
7.2 System Logging
7.2.1 The System Logger
7.2.2 Configuration Files
Facility and Priority
Extended Syntax
Troubleshooting
Logging: Past and Future
7.3 User Management Files
7.3.1 The /etc/passwd File
7.3.2 Special Users
7.3.3 The /etc/shadow File
7.3.4 Manipulating Users and Passwords
Changing /etc/passwd as the Superuser
7.3.5 Working with Groups
7.4 getty and login
7.5 Setting the Time
7.5.1 Kernel Time Representation and Time Zones
7.5.2 Network Time
7.6 Scheduling Recurring Tasks with cron
7.6.1 Installing Crontab Files
7.6.2 System Crontab Files
7.6.3 The Future of cron
7.7 Scheduling One-Time Tasks with at
7.8 Understanding User IDs and User Switching
7.8.1 Process Ownership, Effective UID, Real UID, and Saved UID
Typical Setuid Program Behavior
Security Implications
7.9 User Identification and Authentication
7.9.1 Using Libraries for User Information
7.10 PAM
7.10.1 PAM Configuration
Function Types
Control Arguments and Stacked Rules
Module Arguments
7.10.2 Notes on PAM
7.10.3 PAM and Passwords
7.11 Looking Forward
8. A Closer Look at Processes and Resource Utilization
8.1 Tracking Processes
8.2 Finding Open Files with lsof
8.2.1 Reading the lsof Output
8.2.2 Using lsof
8.3 Tracing Program Execution and System Calls
8.3.1 strace
8.3.2 ltrace
8.4 Threads
8.4.1 Single-Threaded and Multithreaded Processes
8.4.2 Viewing Threads
8.5 Introduction to Resource Monitoring
8.6 Measuring CPU Time
8.7 Adjusting Process Priorities
8.8 Load Averages
8.8.1 Using uptime
8.8.2 High Loads
8.9 Memory
8.9.1 How Memory Works
8.9.2 Page Faults
Minor Page Faults
Major Page Faults
Watching Page Faults
8.10 Monitoring CPU and Memory Performance with vmstat
8.11 I/O Monitoring
8.11.1 Using iostat
8.11.2 Per-Process I/O Utilization and Monitoring: iotop
8.12 Per-Process Monitoring with pidstat
8.13 Further Topics
9. Understanding your Network and its Configuration
9.1 Network Basics
9.1.1 Packets
9.2 Network Layers
9.3 The Internet Layer
9.3.1 Viewing Your Computer’s IP Addresses
9.3.2 Subnets
9.3.3 Common Subnet Masks and CIDR Notation
9.4 Routes and the Kernel Routing Table
9.4.1 The Default Gateway
9.5 Basic ICMP and DNS Tools
9.5.1 ping
9.5.2 traceroute
9.5.3 DNS and host
9.6 The Physical Layer and Ethernet
9.7 Understanding Kernel Network Interfaces
9.8 Introduction to Network Interface Configuration
9.8.1 Manually Adding and Deleting Routes
9.9 Boot-Activated Network Configuration
9.10 Problems with Manual and Boot-Activated Network Configuration
9.11 Network Configuration Managers
9.11.1 NetworkManager Operation
9.11.2 Interacting with NetworkManager
9.11.3 NetworkManager Configuration
Unmanaged Interfaces
Dispatching
9.12 Resolving Hostnames
9.12.1 /etc/hosts
9.12.2 resolv.conf
9.12.3 Caching and Zero-Configuration DNS
9.12.4 /etc/nsswitch.conf
9.13 Localhost
9.14 The Transport Layer: TCP, UDP, and Services
9.14.1 TCP Ports and Connections
9.14.2 Establishing TCP Connections
9.14.3 Port Numbers and /etc/services
9.14.4 Characteristics of TCP
9.14.5 UDP
9.15 Revisiting a Simple Local Network
9.16 Understanding DHCP
9.16.1 The Linux DHCP Client
9.16.2 Linux DHCP Servers
9.17 Configuring Linux as a Router
9.17.1 Internet Uplinks
9.18 Private Networks
9.19 Network Address Translation (IP Masquerading)
9.20 Routers and Linux
9.21 Firewalls
9.21.1 Linux Firewall Basics
9.21.2 Setting Firewall Rules
9.21.3 Firewall Strategies
9.22 Ethernet, IP, and ARP
9.23 Wireless Ethernet
9.23.1 iw
9.23.2 Wireless Security
9.24 Summary
10. Network Applications and Services
10.1 The Basics of Services
10.1.1 A Closer Look
10.2 Network Servers
10.3 Secure Shell (SSH)
10.3.1 The SSHD Server
Host Keys
Starting the SSH Server
10.3.2 The SSH Client
SSH File Transfer Clients
SSH Clients for Non-Unix Platforms
10.4 The inetd and xinetd Daemons
10.4.1 TCP Wrappers: tcpd, /etc/hosts.allow, and /etc/hosts.deny
10.5 Diagnostic Tools
10.5.1 lsof
Filtering by Protocol and Port
Filtering by Connection Status
10.5.2 tcpdump
Primitives
Operators
When Not to Use tcpdump
10.5.3 netcat
10.5.4 Port Scanning
10.6 Remote Procedure Call (RPC)
10.7 Network Security
10.7.1 Typical Vulnerabilities
10.7.2 Security Resources
10.8 Looking Forward
10.9 Sockets: How Processes Communicate with the Network
10.10 Unix Domain Sockets
10.10.1 Advantages for Developers
10.10.2 Listing Unix Domain Sockets
11. Introduction to Shell Scripts
11.1 Shell Script Basics
11.1.1 Limitations of Shell Scripts
11.2 Quoting and Literals
11.2.1 Literals
11.2.2 Single Quotes
11.2.3 Double Quotes
11.2.4 Passing a Literal Single Quote
11.3 Special Variables
11.3.1 Individual Arguments: $1, $2, ...
11.3.2 Number of Arguments: $#
11.3.3 All Arguments: $@
11.3.4 Script Name: $0
11.3.5 Process ID: $$
11.3.6 Exit Code: $?
11.4 Exit Codes
11.5 Conditionals
11.5.1 Getting Around Empty Parameter Lists
11.5.2 Using Other Commands for Tests
11.5.3 elif
11.5.4 && and || Logical Constructs
11.5.5 Testing Conditions
File Tests
String Tests
Arithmetic Tests
11.5.6 Matching Strings with case
11.6 Loops
11.6.1 for Loops
11.6.2 while Loops
11.7 Command Substitution
11.8 Temporary File Management
11.9 Here Documents
11.10 Important Shell Script Utilities
11.10.1 basename
11.10.2 awk
11.10.3 sed
11.10.4 xargs
11.10.5 expr
11.10.6 exec
11.11 Subshells
11.12 Including Other Files in Scripts
11.13 Reading User Input
11.14 When (Not) to Use Shell Scripts
12. Moving Files Across the Network
12.1 Quick Copy
12.2 rsync
12.2.1 rsync Basics
12.2.2 Making Exact Copies of a Directory Structure
12.2.3 Using the Trailing Slash
12.2.4 Excluding Files and Directories
12.2.5 Transfer Integrity, Safeguards, and Verbose Modes
12.2.6 Compression
12.2.7 Limiting Bandwidth
12.2.8 Transferring Files to Your Computer
12.2.9 Further rsync Topics
12.3 Introduction to File Sharing
12.4 Sharing Files with Samba
12.4.1 Configuring the Server
12.4.2 Server Access Control
12.4.3 Passwords
Adding and Deleting Users
Changing Passwords
12.4.4 Starting the Server
12.4.5 Diagnostics and Log Files
12.4.6 Configuring a File Share
12.4.7 Home Directories
12.4.8 Sharing Printers
12.4.9 Using the Samba Client
12.4.10 Accessing Files as a Client
Using the CIFS Filesystem
12.5 NFS Clients
12.6 Further Network File Service Options and Limitations
13. User Environments
13.1 Guidelines for Creating Startup Files
13.2 When to Alter Startup Files
13.3 Shell Startup File Elements
13.3.1 The Command Path
Adding Dot (.) to the Path
13.3.2 The Manual Page Path
13.3.3 The Prompt
13.3.4 Aliases
13.3.5 The Permissions Mask
13.4 Startup File Order and Examples
13.4.1 The bash Shell
Login Shells
Non-Login Shells
The Consequences of Two Kinds of Shells
Example .bashrc
Checking for Login and Interactive Shells
13.4.2 The tcsh Shell
Example .cshrc
13.5 Default User Settings
13.5.1 Shell Defaults
13.5.2 Editor
13.5.3 Pager
13.6 Startup File Pitfalls
13.7 Further Startup Topics
14. A Brief Survey of the Linux Desktop
14.1 Desktop Components
14.1.1 Window Managers
14.1.2 Toolkits
14.1.3 Desktop Environments
14.1.4 Applications
14.2 A Closer Look at the X Window System
14.2.1 Display Managers
14.2.2 Network Transparency
14.3 Exploring X Clients
14.3.1 X Events
14.3.2 Understanding X Input and Preference Settings
Input Devices (General)
Mouse
Keyboard
Desktop Background
xset
14.4 The Future of X
14.5 D-Bus
14.5.1 System and Session Instances
14.5.2 Monitoring D-Bus Messages
14.6 Printing
14.6.1 CUPS
14.6.2 Format Conversion and Print Filters
14.7 Other Desktop Topics
15. Development Tools
15.1 The C Compiler
15.1.1 Multiple Source Files
15.1.2 Header (Include) Files and Directories
Fixing Include File Problems
What Is the C Preprocessor (cpp)?
15.1.3 Linking with Libraries
15.1.4 Shared Libraries
Listing Shared Library Dependencies
How ld.so Finds Shared Libraries
Linking Programs Against Shared Libraries
Problems with Shared Libraries
15.2 make
15.2.1 A Sample Makefile
15.2.2 Built-in Rules
15.2.3 Final Program Build
15.2.4 Staying Up-to-Date
15.2.5 Command-Line Arguments and Options
15.2.6 Standard Macros and Variables
15.2.7 Conventional Targets
15.2.8 Organizing a Makefile
15.3 Debuggers
15.4 Lex and Yacc
15.5 Scripting Languages
15.5.1 Python
15.5.2 Perl
15.5.3 Other Scripting Languages
15.6 Java
15.7 Looking Forward: Compiling Packages
16. Introduction to Compiling Software From C Source Code
16.1 Software Build Systems
16.2 Unpacking C Source Packages
16.2.1 Where to Start
16.3 GNU Autoconf
16.3.1 An Autoconf Example
16.3.2 Installing Using a Packaging Tool
16.3.3 configure Script Options
Using Separate Build Directories
16.3.4 Environment Variables
16.3.5 Autoconf Targets
16.3.6 Autoconf Log Files
16.3.7 pkg-config
How pkg-config Works
Installing pkg-config Files in Nonstandard Locations
16.4 Installation Practice
16.4.1 Where to Install
16.5 Applying a Patch
16.6 Troubleshooting Compiles and Installations
16.6.1 Specific Errors
16.7 Looking Forward
17. Building on the Basics
17.1 Web Servers and Applications
17.2 Databases
17.2.1 Types of Databases
17.3 Virtualization
17.4 Distributed and On-Demand Computing
17.5 Embedded Systems
17.6 Final Remarks
A. Bibliography
B. Updates
Index
About the Author
Copyright
← Prev
Back
Next →
← Prev
Back
Next →