Harley Hahn
Home Page

Send a Message
to Harley

A Personal Note
from Harley Hahn

Unix Book
Home Page

List of Chapters

Table of Contents

List of Figures

   1   2   3
   4   5   6
   7   8   9
  10  11  12
  13  14  15
  16  17  18
  19  20  21
  22  23  24
  25  26


  A  B  C
  D  E  F
  G  H


• Alphabetical
• By category



Errors and



Home Page
& Overview

& Answers

The Unix Model
Curriculum &
Course Outlines

PowerPoint Files
for Teachers

Detailed Table of Contents

  A Personal Note From Harley Hahn
  About the Author
  List of Contents
  Table of Contents
  List of Figures
  Note to Teachers
Chapter 1:   Introduction to Unix
Why Use Unix?
The Unix Language
Hints for Learning Unix
People Who Don't Know They Are Using Unix
People Who Do Know They Are Using Unix
Getting the Most from This Book
What I Assume in This Book
What I Do Not Assume in This Book
How to Use This Book
Chapter 2:   What Is Unix? What Is Linux?
What Is an Operating System?
What Is the Kernel?
Unix = Kernel + Utilities
"Unix" Used to Be a Specific Name
"Unix" Is Now a Generic Name
The Free Software Foundation
Excerpts from the "Gnu Manifesto"
The GPL and Open Source Software
Unix in the 1970s: From Bell Labs to Berkeley
Unix in the 1980s: BSD and System V
Unix in 1991: Waiting for...
...Mr. Right, Linus Torvalds
Linux Distributions
BSD Distributions
What type of Unix Should You Use?
How Do You Get Linux or FreeBSD?
What Is Unix? What Is Linux?
Chapter 3:   The Unix Connection
Humans, Machines and Aliens
In the Olden Days, Computers Were Expensive
Host and Terminals
Terminal Rooms and Terminal Servers
The Console
The Unix Connection
Hosts Without Consoles
The Client/Server Relationship
What Happens When You Press a Key?
Character Terminals and Graphics Terminals
Chapter 4:   Starting to Use Unix
The System Administrator
Userids and passwords
Logging In (Starting Work With Unix)
Getting Down to Work: The Shell Prompt
Logging Out (Stopping Work With Unix): logout, exit, login
Upper- and Lowercase
A Sample Session With Unix
Changing Your Password: passwd
Choosing a Password; Hackers and Crackers
Checking If Someone Has Been Using Your Unix Account: last
Userids and Users
The Superuser Userid (root)
Having Fun While Practicing Safe Computing
Chapter 5:   GUIs: Graphical User Interfaces
What Is a GUI?
X Window
Who Is in Charge of X Window?
Layers of Abstraction
The Window Manager
The Desktop Environment
Layers of Abstraction: Revisited
How the Unix Companies Blew It
KDE and Gnome
CDE and Total Cost of Ownership
Choosing a Desktop Manager
The Grandmother Machine
Chapter 6:   The Unix Work Environment
Doing More Than One Thing at the Time: Part I
The GUI and the CLI
Logging in and Logging out with a GUI
Does Microsoft Windows Have Runlevels?
Learning to Use a GUI
Of Mice and Menus
Resizing, Minimizing, Maximizing and Closing Windows
Controlling the Focus: Task Switching
Multiple Desktops / Workspaces
Terminal Windows
Virtual Consoles
The One and Only Console
Selecting and Inserting
Copying and Pasting
Working as Superuser: su
Entering a Single Command as Superuser: sudo
Configuration Files
Looking Inside a Configuration File
Shutting Down and Rebooting: init, reboot, shutdown
What Happens When the System Starts or Stops? dmesg
Doing More Than One Thing at the Time: Part II
Chapter 7:   Using the Keyboard With Unix
The First Unix Terminals
Teletypes and the Unix Culture
Termcap, Terminfo and curses
How Does Unix Know What Type of Terminal You Are Using?
The Modifier Keys; The Key
The Unix Keyboard Signals
Signals to Use While Typing: erase, werase, kill
The Strangeness of and
The Case of the Mysterious ^H
Stopping a Program: intr
Another Way to Stop a Program: quit
Pausing the Display: stop, start
The End of File Signal: eof
The Shell and the eof Signal
Bash: Trapping the eof Signal
Korn Shell: Trapping the eof Signal
C-Shell: Trapping the eof Signal
Displaying Key Mappings: stty -a
Changing Key Mappings: stty
Command Line Editing
return and linefeed
The Importance of newline
An Important Use for ^J: stty sane, reset
The Fable of the Programmer and the Princess
Chapter 8:   Programs to Use Right Away
Finding a Program on Your System: which, type, whence
How Do You Stop a Program?
Displaying the Time and Date: date
Displaying a Calendar: cal
The Unix Reminder Service: calendar
Information About Your System: uptime, hostname, uname
Information About You: whoami, quota
Information About Other Users: users, who, w
Locking Your Terminal Temporarily: lock
Asking Unix to Remind You When to Leave: leave
A Built-In Calculator: bc
Using bc For Calculations
Using Variables With bc
Using bc With Different Bases
Reverse Polish Notation
The Stack-Based Calculator: dc
Chapter 9:   Documentation: The Unix Manual and Info
The Unix Tradition of Teaching Yourself
What Is the Unix Manual? man
Man Pages
Displaying Man Pages
Two Useful Man Page Techniques
Alternatives to man: xman and the Web
How the Unix Manual in Organized
Specifying the Section Number When Using the man Command
How Man Pages Are Referenced
The Format of a Manual Page
A Quick Way to Find Out What a Command Does: whatis
Searching For a Command: apropos
Foo, Bar and Foobar
The Info System
Info and Trees
Starting Info: info
Learning About Info
Reading an Info File
Jumping From One Node to Another
Chapter 10:   Command Syntax
The Unix Tradition of Teaching Yourself
Entering More Than One Command at a Time
What Happens When You Enter a Command?
Command Syntax
Dash Options and Dash-Dash Options
One or More; Zero or More
The Formal Description of a Command: Syntax
Learning Command Syntax From the Unix Manual
How Can You Learn So Many Options?
Chapter 11:   The Shell
What Is a Shell?
The Bourne Shell Family: sh, ksh, bash
The C-Shell Family: csh, tcsh
Which Shell Should You Use?
Changing Your Shell Temporarily
Changing Your Login Shell: chsh
Chapter 12:   Using the Shell: Variables and Options
Interactive and Non-Interactive Shells
The Environment, Processes and Variables
Environment Variables and Shell Variables
Displaying Environment Variables: env, printenv
Displaying Shell Variables: set
Displaying and Using the Value of a Variable: echo, print
Bourne Shell Family: Using Variables: export, unset
C-Shell Family: Using Variables: setenv, unsetenv, set, unset
Shell Options: set -o, set +o
Displaying Shell Options
Machine-readable, Human-readable
Chapter 13:   Using the Shell: Commands and Customization
Quoting and Escaping
Strong and Weak Quotes
Commands That Are Built Into the Shell: type
Learning About Builtin Commands
External Commands and the Search Path
Modifying Your Search Path
How a Hacker Can Use the Search Path
The Shell Prompt
Modifying the Shell Prompt
Using the Value of a Variable
Which Quotes to Use When Quoting Variables
Special Codes That Use an Escape Character
Command Substitution
Typing Commands and Making Changes
The History List: fc, history
History List: Setting the Size
History List Example: Avoid Deleting the Wrong Files
Displaying Event Number & Working Directory in Your Shell Prompt
Autocompletion: Beyond the Basics
Using Autocompletion for Fun and Profit
Command Line Editing: bindkey
Aliases: alias, unalias
Alias Example: Avoid Deleting the Wrong Files
Alias Example: Reusing Commands From the History List
Alias Example: Displaying Name of Working Directory in Shell Prompt
Suspending an Alias Temporarily
Chapter 14:   Using the Shell: Initialization Files
Initialization Files and Logout Files
Names of Initialization and Logout Files
Dotfiles and rc Files
Using a Simple Text Editor
Login Shells and Non-Login Shells
When are Initialization Files Executed?
A Quick History of Shell Initialization Files
What to Put in Your Initialization Files
Displaying, Creating and Editing Your Initialization Files
Comments in Shell Scripts
Bourne Shell Family: Sample Initialization Files
C-Shell Family: Sample Initialization Files
Chapter 15:   Standard I/O, Redirection, and Pipes
The Unix Philosophy
The New Unix Philosophy
Standard Input, Standard Output and Standard Error
Redirecting Standard Output
Preventing Files From Being Replaced or Created by Redirection
Redirecting Standard Input
File Descriptors; Redirecting Standard Error With the Bourne Shell Family
Redirecting Standard Error With the C-Shell Family
Combining Standard Output and Standard Error
Throwing Away Output
Redirection: Summaries and Experimenting
Splitting a Pipeline: tee
The Importance of Pipelines
Conditional Execution
Chapter 16:   Filters: Introduction and Basic Operations
Variations of Commands and Options
Should You Create Your Own Filters?
The Problem Solving Process
The Simplest Possible Filter: cat
Increasing the Power of Filters
A List of the Most Useful Filters
Combining Files: cat
Splitting Files: split
Combining Files While Reversing Lines: tac
Reversing the Order of Characters: rev
Selecting Lines From the Beginning or End of Data: head, tail
Deleting Columns of Data: colrm
Chapter 17:   Filters: Comparing and Extracting
Comparing Files
Comparing Any Two Files: cmp
Comparing Sorted Text Files: comm
Comparing Unsorted Text Files: diff
Options to Use With diff
Output formats when comparing files: diff, sdiff
Diffs and Patches
Extracting Columns of Data: cut
Records, Fields and Delimiters; Extracting Fields of Data: cut
Combining Columns of Data: paste
Chapter 18:   Filters: Counting and Formatting
Creating line numbers: nl
Counting Lines, Words and Characters: wc
How Unix Uses Tabs
Visualizing Tabs and Spaces
Changing Tabs to Spaces: expand
Changing Spaces to Tabs: unexpand
Formatting Lines: fold
The 80-Character Line
Formatting Paragraphs: fmt
The Olden Days of Printing
Formatting Text Into Pages: pr
Formatting Text Into Columns: pr
Chapter 19:   Filters: Selecting, Sorting, Combining, and Changing
Selecting Lines That Contain a Specified Pattern: grep
The Most Important grep Options
Variations of grep: fgrep, egrep
Selecting Lines Beginning With a Specific Pattern: look
When Do You Use look and When Do You Use grep?
Finding All the Words That Begin With a Specific Pattern: look
Sorting Data: sort
Controlling the Order in Which Data Is Sorted: sort -dfn
Checking If Data Is Sorted: sort -c
The ASCII Code; Collating Sequences
Locales and Collating Sequences
Finding Duplicate Lines: uniq
Merging Sorted Data From Two Files: join
Creating a Total Ordering From Partial Orderings: tsort
Searching for Character Strings in Binary Files: strings
Translating Characters: tr
Translating Unprintable Characters
Translating Characters: Advanced Topics
Non-interactive Text Editing: sed
Using sed for Substitutions
Telling sed to Operate Only on Specific Lines
Using Very Long sed Commands
Chapter 20:   Regular Expressions
Introducing Regular Expressions
The Origin of Regular Expressions
Basic and Extended Regular Expressions
Matching Lines and Words
Matching Characters; Character Classes
Predefined Character Classes; Ranges
Locales and Collating Sequences; the ASCII Code
Using Ranges and Predefined Character Classes
Repetition Operators
How to Understand a Complex Regular Expression
Solving Three Interesting Puzzles
Chapter 21:   Displaying Files
Survey of Programs Used To Display Files
Introduction to less: Starting, Stopping, Help
The Story of less and more
Using less
Using less to Search Within a File
Raw and Cooked Mode
Options to Use With less
When to Use less and When to Use cat
Using Environment Variables to Customize Your Pager
Displaying Multiple Files With less
Displaying a File Using more
Displaying the Beginning of a File: head
Displaying the End of a File: tail
Watching the End of a Growing File: tail -f
Binary, Octal and Hexadecimal
Reading and Writing Binary, Octal and Hexadecimal
Why We Use Hexadecimal Rather Than Octal
Displaying Binary Files: hexdump, od
Why Does So Much Computer Terminology Come From Mathematics?
Chapter 22:   The vi Text Editor
Why vi Is So Important
A Quick History of vi
Vim: an Alternative to vi
Starting vi
Starting Vim: vim
Command Mode and Input Mode
Knowing What Mode You Are In
Starting vi As a Read-Only Editor: view, vi -R
Recovering Data After a System Failure
Stopping vi
How vi Uses the Screen
Using vi and ex Commands
A Strategy for Learning vi Commands
Creating a Practice File
Moving the Cursor
Moving Through the Editing Buffer
Jumping to a Previous Location
Searching for a Pattern
Using Line Numbers
Inserting Text
Changing Text
Replacing Text
Deleting Text
Undoing or Repeating a Change
Recovering Deletions
Moving Text
Copying Text
Changing the Case of Letters
Setting Options
Displaying Options
Breaking Lines Automatically As You Type
Breaking and Joining Lines
Copying and Moving Lines
Entering Shell Commands
Inserting Data From a File Into the Editing Buffer
Inserting the Output of a Shell Command Into the Editing Buffer
Using a Program to Process Data: fmt
Writing Data to a File
Changing to a New File
Using Abbreviations
Initialization Files: .exrc, .vimrc
Using Two Initialization Files
Learning to Use Vim
It's Always Something
Chapter 23:   The Unix Filesystem
What Is a File?
Types of Files
Directories and Subdirectories
Special Files
Special Files for Hardware
Special Files for Terminals: tty
Special Files for Pseudo-Devices
Named Pipes: mkfifo
Proc Files
The Tree-Structured Filesystem; The Filesystem Hierarchy Standard
The Root Directory; Subdirectories
Mounting a Filesystem: mount, umount
A Tour of the Root Directory
A Tour of the /usr Directory
Why Is There More Than One Directory for Programs?
Home Directories
The Virtual File System
Chapter 24:   Working With Directories
Pathnames and Your Working Directory
Absolute and Relative Path Names
Three Handy Pathname Abbreviations:  ..  .  ~
Moving Around the Directory Tree: cd, pwd
Making a New Directory: mkdir
Removing a Directory: rmdir
Moving or Renaming a Directory: mv
Using the Directory Stack: pushd, popd, dirs
The Most Important Program of All: ls
Listing the Contents of a Directory: ls -CrR1
Collating sequences, Locales and ls
Checking File Types, Part I: ls -F
Checking File Types, Part II: ls --color
Checking File Types, Part III: file
Keeping Track of Your Disk Space Usage: ls -hs, du, df, quota
How Big Is a File? Blocks and Allocation Units: dumpe2fs
Globbing with Wildcards
Dot Files (Hidden Files): ls -a
Long Directory Listings: ls -dhltu
Useful Aliases for Using ls
Displaying a Directory Tree: tree
Chapter 25:   Working With Files
Creating a File: touch
Naming a File
Copying a File: cp
Copying Files to a Different Directory: cp
Copying a Directory to Another Directory: cp -r
Moving a File: mv
Renaming a File or Directory: mv
Deleting a File: rm
How to Keep From Deleting the Wrong Files: rm -if
Deleting an Entire Directory Tree: rm -r
Is It Possible to Restore a File That Has Been Deleted?
File Permissions
How Unix Maintains File Permissions: id, groups
Displaying File Permissions: ls -l
File Modes
Changing File Permissions: chmod
How Unix Assigns Permissions to a New File: umask
Wiping Out the Contents of a File: shred
The Idea of a Link: stat, ls -i
Multiple Links to the Same File
Creating a New Link: ln
How The Basic File Commands Work
Symbolic Links: ln -s
Using Symbolic Links With Directories
Finding Files Associated With a Unix Command: whereis
Finding Files by Searching a Database: locate
Finding Files by Searching a Directory Tree: find
The find Command: Paths
The find Command: Tests
The find Command: Negating a Test With the ! Operator
The find Command: Dealing With File Permission Error Messages
The find Command: Actions
Processing Files That Have Been Found: xargs
Chapter 26:   Processes and Job Control
How the Kernel Manages Processes
Forking Till You Die
Orphans and Abandoned Processes
Distinguishing Between Parent and Child
The Very First Process: init
Foreground and Background Processes
Creating a Delay: sleep
Job Control
Running a Job in the Background
Suspending a Job: fg
Suspending a Shell: suspend
Job Control vs. Multiple Windows
Displaying a List of Your Jobs: jobs
Moving a Job to the Foreground: fg
Moving a Job to the Background: bg
Learning to Use the ps Program
The ps Program: Basic Skills
The ps Program: Choosing Options
The ps Program: States
Monitoring System Processes: top, prstat
Displaying a Process Tree: pstree, ptree
Thinking About How Unix Organizes Process and Files: fuser
Killing a Process: kill
Sending a Signal to a Process: kill
Setting the Priority for a Process: nice
Changing the Priority of an Existing Process: renice
The End of the Last Chapter
Appendix A   Summary of Unix Commands Covered in This Book
Appendix B   Summary of Unix Commands by Category
Appendix C   Summary of vi Commands
Appendix D   The ASCII Code
Appendix E   What to Do If You Forget the Root Password
Appendix F   Time Zones and 24-Hour Time
Appendix G   Shell Options and Shell Variables
Appendix H   The Unix/Linux Timel
  Exercises and Answers

Indexes   Quick Index for the vi Text Editor
    General Index
    Quick Index of Unix Commands  [inside back cover]

Jump to top of page