You are on page 1of 31

1.Quick Tour.

pdf

Table of Contents
1. Logging In ................................................................................................................... 4
Discussion .............................................................................................................. 4
Starting Linux Sessions ..................................................................................... 4
Virtual Consoles .............................................................................................. 4
The X Graphical Environment ............................................................................ 5
Terminals in the Graphical environment ............................................................... 6
Logging out from the graphical environment ......................................................... 8
Using the who command to determine who's on the system. ..................................... 9
Logging into a machine over the network ............................................................. 9
Examples .............................................................................................................. 10
Example 1. Using virtual consoles ...................................................................... 10
Online Exercises .................................................................................................... 11
Online Exercise 1. Using multiple virtual consoles ................................................. 11
Specification .......................................................................................... 11
Deliverables ........................................................................................... 12
Questions .............................................................................................................. 12
2. The Kernel, Programs, and Processes ............................................................................... 14
Discussion ............................................................................................................. 14
The Linux Kernel ........................................................................................... 14
Programs ....................................................................................................... 15
Processes ...................................................................................................... 15
Shells ........................................................................................................... 16
The ps command ............................................................................................ 16
Questions .............................................................................................................. 17
The kernel, programs, and processes .................................................................. 17
3. Examining the Filesystem .............................................................................................. 19
Discussion ............................................................................................................. 19
The Naming of Files and Directories .................................................................. 19
Listing directory contents with ls ....................................................................... 19
Viewing the contents of a file with cat ............................................................... 20
Redirecting command output to files .................................................................. 20
Permissions, and a user's home directory. ............................................................ 21
Examples .............................................................................................................. 21
Example 1. Redirecting command output to a file. ................................................. 21
Online Exercises .................................................................................................... 22
Online Exercise 1. The ls Command ................................................................... 22
Specification .......................................................................................... 22
Deliverables ........................................................................................... 22
Possible Solution .................................................................................... 22
Questions .............................................................................................................. 22
Multiple Choice Questions. .............................................................................. 22
4. Running Commands ..................................................................................................... 24
Discussion ............................................................................................................. 24
Command Line Grammar ................................................................................. 24
Commands .................................................................................................... 24
Command Line Switches ................................................................................. 25
Short Command Line Switches ................................................................. 25
Multiple Short Command Line Switches ..................................................... 25
Long Command Line Switches .................................................................. 26
Arguments ..................................................................................................... 26
Getting Help: Usage ........................................................................................ 27
Quick Tour
3
Examples .............................................................................................................. 27
Example 1. Learning to Use the cat Command ...................................................... 27
Questions .............................................................................................................. 29
Command Line Syntax .................................................................................... 29
5. Managing Terminals ..................................................................................................... 32
Discussion ............................................................................................................. 32
Controlling Terminals ...................................................................................... 32
Resetting Terminals ........................................................................................ 32
Terminal control sequences .............................................................................. 32
Identifying terminals ....................................................................................... 35
Tab Completion ............................................................................................. 36
Examples .............................................................................................................. 37
Example 1. Resetting the terminal after viewing a binary file. ................................... 37
Example 2. Canceling a command ...................................................................... 37
Online Exercises .................................................................................................... 38
Online Exercise 1. Suspending terminal output ...................................................... 38
Specification .......................................................................................... 38
Deliverables ........................................................................................... 38
Cleaning Up .......................................................................................... 38
Online Exercise 2. Sorting your socks. ................................................................ 38
Specification .......................................................................................... 38
Deliverables ........................................................................................... 39
Questions .............................................................................................................. 39
6. Getting Help ............................................................................................................... 42
Discussion ............................................................................................................. 42
Getting Help .................................................................................................. 42
Obtaining Usages with -h, -?, and --help ............................................................. 42
Man Pages .................................................................................................... 42
The less Pager ....................................................................................... 43
Man Chapters ........................................................................................ 43
Keyword Searches, and the -a Switch. ........................................................ 43
Info Pages ..................................................................................................... 44
The /usr/share/doc Directory ............................................................................. 44
Red Hat Documentation Guides ........................................................................ 45
The Linux Documentation Project ..................................................................... 45
yelp: The Gnome Help Browser ........................................................................ 46
Questions .............................................................................................................. 4

2.Filesystem Basics .pdf


1. Filesystem Navigation .................................................................................................... 5
Discussion .............................................................................................................. 5
The Filesystem Inverted Tree ............................................................................. 5
Exploring the Directory Tree using Nautilus .......................................................... 6
The Current Working Directory (cwd) .................................................................. 9
Where Am I? The pwd command ........................................................................ 9
Moving Around - The cd command ................................................................... 10
Absolute and Relative References ...................................................................... 11
Examples .............................................................................................................. 12
Example 1. Discovering your home directory ........................................................ 12
Example 2. Climbing up and down the tree. ......................................................... 12
Online Exercises .................................................................................................... 13
Online Exercise 1. Exploring the filesystem .......................................................... 13
Specification .......................................................................................... 13
Deliverables ........................................................................................... 13
Possible Solution .................................................................................... 13
Questions .............................................................................................................. 13
Navigating the Filesystem ................................................................................ 13
2. Important Directories .................................................................................................... 15
Discussion ............................................................................................................. 15
Standard Linux Directory Scheme ..................................................................... 15
The User's Home Directory .............................................................................. 15
The /tmp Temporary Directory .......................................................................... 16
The /etc Configuration Directory ....................................................................... 16
The /bin and /usr/bin Command Directories ......................................................... 16
The /sbin and /usr/sbin Command Directories ....................................................... 17
The /var "Variable" Directory ........................................................................... 17
root vs. /root vs. / (the filesystem root) ............................................................... 17
Examples .............................................................................................................. 17
Example 1. The /tmp Directory .......................................................................... 17
Example 2. Looking for commands in /bin and /usr/bin ........................................... 18
Online Exercises .................................................................................................... 18
Online Exercise 1. Exploring Important Directories ................................................ 18
Setup .................................................................................................... 19
Specification .......................................................................................... 19
Deliverables ........................................................................................... 19
Possible Solution .................................................................................... 19
Questions .............................................................................................................. 19
3. Managing Files ............................................................................................................ 22
Discussion ............................................................................................................. 22
Redirection .................................................................................................... 22
Copy files with cp .......................................................................................... 23
Examples: ............................................................................................. 23
Move/rename files with mv .............................................................................. 24
Examples: ............................................................................................. 24
Remove (delete) files with rm ........................................................................... 25
Examples: ............................................................................................. 25
Clobbering files (oops!) ................................................................................... 26
Examples .............................................................................................................. 27
Example 1. Moving/Archiving a Simple Website ................................................... 27
Example 2. Moving a Simple Website ................................................................. 28
Filesystem Basics
3
Example 3. Removing robots.txt ......................................................................... 28
Online Exercises .................................................................................................... 28
Online Exercise 1. Create a Website ................................................................... 28
Setup .................................................................................................... 28
Specification .......................................................................................... 28
Deliverables ........................................................................................... 29
Possible Solution .................................................................................... 29
Online Exercise 2. Investigate the "noclobber" option ............................................. 29
Specification .......................................................................................... 29
Deliverables ........................................................................................... 30
Possible Solution .................................................................................... 30
Questions .............................................................................................................. 30
4. Managing Directories .................................................................................................... 33
Discussion ............................................................................................................. 33
Creating (new, empty) directories: mkdir ............................................................ 33
Listing Directory Trees .................................................................................... 34
Removing (empty) directories: rmdir .................................................................. 34
Listing Directory Trees .................................................................................... 34
Copying directory trees: cp -r ........................................................................... 35
Removing directory trees: rm -r ........................................................................ 37
Examining Directories with tree ........................................................................ 38
Examples .............................................................................................................. 38
Example 1. Making a Backup of a Directory Tree .................................................. 38
Example 2. Creating a Local Copy of Example Files .............................................. 40
Online Exercises .................................................................................................... 40
Online Exercise 1. Managing Directories ............................................................. 40
Specification .......................................................................................... 40
Deliverables ........................................................................................... 41
Cleaning Up .......................................................................................... 41
Questions .............................................................................................................. 41
5. File Names and File Globbing ........................................................................................ 45
Discussion ............................................................................................................. 45
Filenames ...................................................................................................... 45
Hidden Files .................................................................................................. 46
"Globbing" .................................................................................................... 47
Examples .............................................................................................................. 48
Example 1. Finding That Configuration File ......................................................... 48
Example 2. Listing Static Libraries ..................................................................... 49
Example 3. Listing Man Pages ........................................................................... 50
Online Exercises .................................................................................................... 50
Online Exercise 1. Managing Files with File Globbing ............................................ 50
Specification .......................................................................................... 51
Deliverables ........................................................................................... 51
Suggestions ........................................................................................... 52
Questions .............................................................................................................. 52
6. Examining Files ........................................................................................................... 56
Discussion ............................................................................................................. 56
Viewing Files ................................................................................................ 56
The file Command .......................................................................................... 56
The cat Command .......................................................................................... 56
The more and less Pagers ................................................................................ 57
The head Command ........................................................................................ 58
The tail Command .......................................................................................... 59
Examples .............................................................................................................. 60
Filesystem Basics
4
Example 1. Identifying Documents with file ......................................................... 60
Example 2. Determining the Correct File Type with file .......................................... 60
Example 3. Skimming Files with head ................................................................. 61
Example 4. Combining Multiple Files into a Single File with head ............................ 61
Example 5. Monitoring Multiple Files with tail ..................................................... 62
Online Exercises .................................................................................................... 63
Online Exercise 1. Browsing Text Files ............................................................... 63
Specification .......................................................................................... 63
Deliverables ........................................................................................... 64
Cleaning Up .......................................................................................... 64
Questions .............................................................................................................. 64
7. Editing Files ............................................................................................................... 67
Discussion ............................................................................................................. 67
Text Editor vs. Word Processor ......................................................................... 67
Text Editors in Linux ...................................................................................... 67
nano ............................................................................................................. 67
gedit ............................................................................................................. 68
Online Exercises .................................................................................................... 69
Online Exercise 1. Text Editors .......................................................................... 69
Specification .......................................................................................... 69
Deliverables ...........................................................................................
3.Users and Groups.pdf
1. Linux Users and the /etc/passwd File ................................................................................. 4
Discussion .............................................................................................................. 4
Linux Users and the /etc/passwd file. ................................................................... 4
User Passwords and the /etc/shadow file. .............................................................. 5
Three types of users: normal, root, and system ....................................................... 6
Examples ................................................................................................................ 7
Example 1. Examining process userids .................................................................. 7
Example 2. Examining File Owners by username and userid ...................................... 8
Example 3. Changing a username, as root. ............................................................. 8
Online Exercises ...................................................................................................... 9
Online Exercise 1. Determining User Information .................................................... 9
Specification ........................................................................................... 9
Deliverables ............................................................................................ 9
Questions .............................................................................................................. 10
2. Linux Groups and the /etc/group File ............................................................................... 12
Discussion ............................................................................................................. 12
Linux Groups ................................................................................................ 12
The /etc/group file. .......................................................................................... 12
Why groups? ................................................................................................. 13
Primary and Secondary Groups ......................................................................... 13
How do I change my group memberships? .......................................................... 14
Examples .............................................................................................................. 14
Example 1. Who are members of that group? ........................................................ 14
Example 2. What groups does that user belong to? ................................................. 15
Online Exercises .................................................................................................... 15
Online Exercise 1. Determining group memberships ............................................... 15
Specification .......................................................................................... 15
Deliverables ........................................................................................... 16
Online Exercise 2. Determining a user's subscribed groups (the hard way) ................... 16
Specification .......................................................................................... 16
Deliverables ........................................................................................... 16
Questions .............................................................................................................. 16
Group memberships ........................................................................................ 16
3. Examining User Information .......................................................................................... 20
Discussion ............................................................................................................. 20
Identifying users: the id command. .................................................................... 20
The whoami command. ................................................................................... 21
Who is currently logged on? The users, w, and who commands. ............................... 21
Checking up on users: the finger command. ......................................................... 22
Using the finger command. ...................................................................... 22
Customizing finger command output. ......................................................... 23
Using the finger command over the network. ............................................... 24
Examples .............................................................................................................. 24
Example 1. Using the id command to determine group memberships. ......................... 24
Example 2. Catching up with elvis. ..................................................................... 24
Online Exercises .................................................................................................... 25
Online Exercise 1. Listing groups with the id command. ......................................... 25
Specification .......................................................................................... 25
Deliverables ........................................................................................... 25
Questions .............................................................................................................. 25
Determining user information ........................................................................... 25
Users and Groups
3
4. Changing Identity ......................................................................................................... 27
Discussion ............................................................................................................. 27
Switching identity ........................................................................................... 27
Becoming root ............................................................................................... 28
Switching primary group with the newgrp (or sg) command. ................................... 28
Examples .............................................................................................................. 29
Example 1. The su command and sessions. ........................................................... 29
Online Exercises .................................................................................................... 29
Online Exercise 1. Using the newgrp command to change primary groups. .................. 29
Specification .......................................................................................... 29
Deliverables ........................................................................................... 30
Possible Solution .................................................................................... 30
Questions .............................................................................................................. 30
Switching userid and group .............................................................................. 30

4.File Ownerships and Permissions.pdf


1. Regular File Ownerships and Permissions .......................................................................... 4
Discussion .............................................................................................................. 4
User Owners, Group Owners, and Permissions ...................................................... 4
The Three Permission Types: (r)ead, (w)rite, and e(x)ecute ...................................... 5
Three Access Classes: (u)ser owner, (g)roup owner, and (o)ther. ................................ 5
Examples ................................................................................................................ 5
Example 1. Newly created files ............................................................................ 5
Example 2. Group shared files ............................................................................. 6
Example 3. Executable files ................................................................................ 6
Example 4. Symbolic Links ................................................................................ 7
Online Exercises ...................................................................................................... 7
Online Exercise 1. Explore permissions on newly created files ................................... 7
Deliverables ............................................................................................ 8
Questions ................................................................................................................ 8
Analyzing File Permissions ................................................................................ 8
2. Changing File Permissions: chmod .................................................................................. 11
Discussion ............................................................................................................. 11
Examples .............................................................................................................. 12
Example 1. Using chmod on files ....................................................................... 12
Online Exercises .................................................................................................... 13
Online Exercise 1. Making a File Private ............................................................. 13
Deliverables ........................................................................................... 13
Questions .............................................................................................................. 13
3. Changing File Ownerships with chgrp and chown .............................................................. 16
Discussion ............................................................................................................. 16
Changing File Group Owners with chgrp ............................................................ 16
Changing File User Owners with chown ............................................................. 17
Who can Modify a File's Owners and Permissions? ............................................... 17
Examples .............................................................................................................. 17
Example 1. Managing Group Files ...................................................................... 17
Online Exercises .................................................................................................... 18
Online Exercise 1. Sharing a file with a group ...................................................... 18
Specifications ......................................................................................... 18
Deliverables ........................................................................................... 19
Questions .............................................................................................................. 19
4. Directory Ownerships and Permissions ............................................................................. 22
Discussion ............................................................................................................. 22
Directory Permissions ...................................................................................... 22
Examples .............................................................................................................. 23
Example 1. New Directory Defaults .................................................................... 23
Example 2. Home Directories ............................................................................ 23
Example 3. Creating a ~/pub Directory ................................................................ 24
Example 4. Protecting Home's Subdirectories ........................................................ 25
Online Exercises .................................................................................................... 26
Online Exercise 1. Creating Public Directories for Distinct Groups ............................ 26
Specifications ......................................................................................... 26
Deliverables ........................................................................................... 27
Hints .................................................................................................... 27
Online Exercise 2. Protecting Subdirectories within Home ....................................... 28
Deliverables ........................................................................................... 28
Questions .............................................................................................................. 28
File Ownerships and Permissions
3
Analyzing Directory Permissions ....................................................................... 28
5. chmod Revisited: Octal Notation ..................................................................................... 32
Discussion ............................................................................................................. 32
Why a different syntax? ................................................................................... 32
Where did 600 come from? .............................................................................. 32
File modes .................................................................................................... 33
Examples .............................................................................................................. 33
Example 1. Creating a ~/pub Directory (using Octal Notation) .................................. 33
Example 2. Misuse of Recursive Octal Notation .................................................... 33
Online Exercises .................................................................................................... 34
Online Exercise 1. Managing Permissions on Groups of Files ................................... 34
Setup .................................................................................................... 34
Specification .......................................................................................... 35
Deliverables ........................................................................................... 35
Possible Solution .................................................................................... 35
Questions .............................................................................................................. 36
Analyzing Directory Permissions ....................................................................... 36
6. Controlling Default Permissions: umask ........................................................................... 38
Discussion ............................................................................................................. 38
Controlling default permissions with umask ......................................................... 38
Default Permissions for files ............................................................................. 38
Default Permissions for directories ..................................................................... 39
Modifying the shell's umask: the umask command ................................................ 39
Examples .............................................................................................................. 39
Example 1. Using umask to Create Group Shared Files ........................................... 39
Example 2. Using ~/.bashrc to automatically change the bash shell's umask ................. 40
Online Exercises .................................................................................................... 41
Online Exercise 1. Changing the bash shell's default permissions. .............................. 41
Specification .......................................................................................... 41
Deliverables ........................................................................................... 41
Possible Solution .................................................................................... 41
Cleaning Up .......................................................................................... 42
Questions .............................................................................................................. 42
Understanding the implications of a process's umask ............................................. 4

5.The Linux Filesystem.pdf


1. File Details ................................................................................................................... 5
Discussion .............................................................................................................. 5
How Linux Save Files ...................................................................................... 5
What's in an inode? .......................................................................................... 6
Viewing inode information with the stat command ................................................. 9
Viewing inode information with the ls command .................................................. 10
Identifying Files by Inode ................................................................................ 10
Examples .............................................................................................................. 11
Example 1. Comparing file sizes with ls -s and ls -l ............................................... 11
Example 2. Listing files, sorted by modify time ..................................................... 11
Example 3. Decorating listings with ls -F ............................................................. 12
Online Exercises .................................................................................................... 13
Online Exercise 1. Viewing file metadata ............................................................. 13
Specification .......................................................................................... 13
Deliverables ........................................................................................... 13
Suggestions ........................................................................................... 13
Questions .............................................................................................................. 13
2. Hard and Soft Links ..................................................................................................... 17
Discussion ............................................................................................................. 17
The Case for Hard Links ................................................................................. 17
Hard Link Details ........................................................................................... 17
The Case for Soft Links .................................................................................. 19
Soft Link Details ............................................................................................ 20
Creating Links with the ln Command ................................................................. 20
Issues with Soft Links ..................................................................................... 21
Dangling Links ...................................................................................... 21
Recursive links ....................................................................................... 22
Absolute vs. Relative Soft Links ............................................................... 23
Comparing Hard and Soft Links ........................................................................ 23
Examples .............................................................................................................. 23
Example 1. Working with hard links ................................................................... 23
Example 2. Working with soft links .................................................................... 24
Example 3. Working with soft links and directories ................................................ 25
Online Exercises .................................................................................................... 25
Online Exercise 1. Creating and Managing Links ................................................... 25
Specification .......................................................................................... 25
Deliverables ........................................................................................... 26
Online Exercise 2. Sharing a Hard Linked File ...................................................... 26
Specification .......................................................................................... 26
Deliverables ........................................................................................... 27
Questions .............................................................................................................. 27
3. Directories and Device Nodes ........................................................................................ 30
Discussion ............................................................................................................. 30
Directories ..................................................................................................... 30
Directory Structure ................................................................................. 30
Directory Links ...................................................................................... 31
Device Nodes ................................................................................................ 33
Block and Character Device Nodes ............................................................ 33
Terminals as Devices .............................................................................. 34
Device Permissions, Security, and the Console User ...................................... 35
Examples .............................................................................................................. 36
The Linux Filesystem
3
Example 1. Interpreting Directory Links Counts .................................................... 36
Questions .............................................................................................................. 37
4. Disks, Filesystems, and Mounting ................................................................................... 40
Discussion ............................................................................................................. 40
Disk Devices ................................................................................................. 40
Low Level Access to Drives ............................................................................. 41
Filesystems .................................................................................................... 42
Mounting Filesystems ...................................................................................... 43
Viewing Mount Points ............................................................................. 44
Why Bother? ......................................................................................... 44
Mounting Temporary Media: The /media directory. ....................................... 45
Mounting Issues ..................................................................................... 46
Examples .............................................................................................................. 47
Example 1. Using an Unformatted Floppy ............................................................ 47
Example 2. Using a DOS Formatted Floppy ......................................................... 48
Example 3. Floppy Images ................................................................................ 49
Online Exercises .................................................................................................... 49
Online Exercise 1. Using Floppies ...................................................................... 49
Setup .................................................................................................... 49
Specification .......................................................................................... 50
Deliverables ........................................................................................... 50
Possible Solution .................................................................................... 50
Cleaning Up .......................................................................................... 50
Online Exercise 2. Imaging a Floppy ................................................................... 50
Setup .................................................................................................... 51
Specification .......................................................................................... 51
Deliverables ........................................................................................... 51
Possible Solution .................................................................................... 51
Cleaning Up .......................................................................................... 51
Questions .............................................................................................................. 51
5. Locating Files with locate and find ................................................................................. 55
Discussion ............................................................................................................. 55
Locating Files ................................................................................................ 55
Using Locate ................................................................................................. 55
Using find ..................................................................................................... 56
Find Criteria .......................................................................................... 57
Find Actions .......................................................................................... 58
Examples .............................................................................................................. 59
Example 1. Using locate ................................................................................... 59
Example 2. Using find ...................................................................................... 60
Example 3. Using find to Execute Commands on Files ........................................... 60
Online Exercises .................................................................................................... 61
Online Exercise 1. Locating files ........................................................................ 61
Specification .......................................................................................... 61
Deliverables ........................................................................................... 61
Questions .............................................................................................................. 62
6. Compressing Files: gzip and bzip2 .................................................................................. 64
Discussion ............................................................................................................. 64
Why Compress Files? ...................................................................................... 64
Standard Linux Compression Utilities ................................................................. 64
Other Compression Utilities .............................................................................. 65
Examples .............................................................................................................. 65
Example 1. Working with gzip ........................................................................... 65
Example 2. Using gzip Recursively ..................................................................... 65
The Linux Filesystem
4
Example 3. Working with bzip2 ......................................................................... 66
Online Exercises .................................................................................................... 66
Online Exercise 1. Working with compression Utilities ........................................... 66
Specification .......................................................................................... 66
Deliverables ........................................................................................... 67
Questions .............................................................................................................. 67
7. Archiving Files with tar ................................................................................................ 69
Discussion ............................................................................................................. 69
Archive Files ................................................................................................. 69
Tar Command Basics ...................................................................................... 69
More About tar .............................................................................................. 70
Absolute References ................................................................................ 71
Establishing Context ............................................................................... 72
Compressing archives .............................................................................. 73
Examples .............................................................................................................. 73
Example 1. Creating a tar Archive ...................................................................... 73
Example 2. Tarring Directly to a Floppy .............................................................. 74
Example 3. Oops. ............................................................................................ 75
Online Exercises .................................................................................................... 75
Online Exercise 1. Archiving Directories ............................................................. 75
Specification .......................................................................................... 75
Deliverables ........................................................................................... 75
Questions .............................................................................................................. 7

6.The Bash Shell.pdf


1. Introduction to Bash ....................................................................................................... 5
Discussion .............................................................................................................. 5
The bash shell ................................................................................................. 5
Interactive Shells vs. Shell Scripts ....................................................................... 5
Starting Shells ................................................................................................. 5
The ~/.bashrc File .................................................................................... 6
Entering Commands ......................................................................................... 7
Command History ............................................................................................ 7
History Substitution .................................................................................. 7
Preserving History Between Sessions ........................................................... 8
Command History Tricks ........................................................................... 8
Examples ................................................................................................................ 9
Example 1. Using command history to shorten the "Edit/Compile/Execute" cycle ........... 9
Example 2. Using ESC. .................................................................................... 10
Example 3. Inhibiting Command History ............................................................. 10
Online Exercises .................................................................................................... 10
Specification .................................................................................................. 10
Deliverables ................................................................................................... 11
Questions .............................................................................................................. 11
2. Command Lists and Scripts ........................................................................................... 14
Discussion ............................................................................................................. 14
Running Multiple Commands ........................................................................... 14
Running Commands in a Subshell ..................................................................... 14
An Introduction to Shell Scripts ........................................................................ 15
Return Values ........................................................................................ 16
Running Multiple Commands Conditionally ................................................. 17
Examples .............................................................................................................. 18
Example 1. Echoing $? twice ............................................................................. 18
Example 2. Displaying Reminders ...................................................................... 18
Online Exercises .................................................................................................... 19
Specification .................................................................................................. 19
Deliverables ................................................................................................... 19
Clean Up ...................................................................................................... 19
Questions .............................................................................................................. 19
3. Shell Variables ............................................................................................................ 22
Discussion ............................................................................................................. 22
Shell Variable Basics ...................................................................................... 22
Shell Variable Details ...................................................................................... 23
Bash Variables ............................................................................................... 24
Environment Variables .................................................................................... 25
Listing Variables ............................................................................................ 26
Examining variables with set and env ......................................................... 26
Commonly Used Environment Variables ............................................................. 26
Examples .............................................................................................................. 27
Example 1. Using Variables to Reference Commonly Used Words ............................ 27
Example 2. Using http_proxy to Define a HTTP Proxy Server .................................. 27
Example 3. Appending a Directory to Your PATH ................................................. 28
Online Exercises .................................................................................................... 29
Specification .................................................................................................. 29
Deliverables ................................................................................................... 30
Cleaning Up .................................................................................................. 30
The Bash Shell
3
Questions .............................................................................................................. 30
4. Command Line Expansion ............................................................................................. 34
Discussion ............................................................................................................. 34
Command Line Expansions .............................................................................. 34
Overview .............................................................................................. 34
History Expansion .................................................................................. 34
Brace Expansion ..................................................................................... 34
Tilde Expansion ..................................................................................... 35
Variable Expansion ................................................................................. 36
Arithmetic Expansion .............................................................................. 36
Command Substitution ............................................................................. 36
Pathname Expansion ("File Globbing") ....................................................... 37
Quoting and Escaping Characters ...................................................................... 37
A Note on Quotes .......................................................................................... 38
Command Line Expansion Subtleties ................................................................. 38
Examples .............................................................................................................. 39
Example 1. Using Brace Expansion .................................................................... 39
Example 2. More Tab Completion ...................................................................... 40
Example 3. Quoting Awkward Filenames ............................................................. 40
Online Exercises .................................................................................................... 41
Specification .................................................................................................. 41
Deliverables ................................................................................................... 42
Questions .............................................................................................................. 42
5. Shell Customizations .................................................................................................... 46
Discussion ............................................................................................................. 46
Shell Builtins ................................................................................................. 46
Aliases .......................................................................................................... 47
The alias Command ................................................................................ 47
The unalias Command ............................................................................. 48
Evaluating Aliases .................................................................................. 48
Running Commands ................................................................................ 49
Customizing the Bash Prompt ........................................................................... 49
Customizing Bash Prompts with PS1 and PS2 .............................................. 49
Bash Shell Flags and Shell Options .................................................................... 50
Shell Flags: The set Builtin Command ........................................................ 50
Shell Options: The shopt Builtin Command ................................................. 51
Examples .............................................................................................................. 52
Example 1. Red Hat Enterprise Linux Default Aliases ............................................ 52
Example 2. Using Aliases to Create Safer rm, mv, and cp Commands ........................ 53
Example 3. Using Aliases to Create Timestamps ................................................... 54
Online Exercises .................................................................................................... 56
Specification .................................................................................................. 56
Challenge Exercise ......................................................................................... 56
Deliverables ................................................................................................... 57
Questions .............................................................................................................. 57
6. Sourcing Shell Scripts and Shell Initialization ................................................................... 60
Discussion ............................................................................................................. 60
Sourcing Scripts ............................................................................................. 60
Bash Initialization: /etc/profile, ~/.profile, ~/.bashrc, and /etc/bashrc ......................... 61
Login, Non-login, Interactive, and Non-interactive Shells ............................... 61
Bash Startup Scripts ................................................................................ 62
Why are there Login and Non-Login Shells? ................................................ 63
Why are there Interactive and Non-Interactive shells? .................................... 64
Exiting Login Shells: ~/.bash_logout .................................................................. 64
The Bash Shell
4
Examples .............................................................................................................. 64
Example 1. The su Command, Revisited .............................................................. 64
Example 2. Explicitly sourceing /etc/profile and ~/.bash_profile ................................ 65
Online Exercises .................................................................................................... 65
Specification .................................................................................................. 65
Deliverables ................................................................................................... 65
Questions .............................................................................................................. 6

7.rha030-workbook08-student-6.1-2.pdf
1. Standard In and Standard Out .......................................................................................... 3
Discussion .............................................................................................................. 3
Three types of programs .................................................................................... 3
Standard in (stdin) and Standard out (stdout) ......................................................... 4
Redirecting stdout ............................................................................................ 4
Writing Output to a File ............................................................................ 4
Appending Output to a File ........................................................................ 4
Redirecting stdin .............................................................................................. 5
Under the Hood: Open Files and File Descriptors ................................................... 5
Open Files and File Descriptors .................................................................. 5
Redirection .............................................................................................. 7
Examples ................................................................................................................ 8
Example 1. Getting Out of sort's .......................................................................... 8
Example 2. Automated FTP Transfers ................................................................... 9
Example 3. Automating Graph Generation with gnuplot .......................................... 11
Online Exercises .................................................................................................... 12
Online Exercise 1. Using Standard In and Standard Out .......................................... 12
Specification .......................................................................................... 12
Deliverables ........................................................................................... 13
Suggested Strategy for Automating gnuplot ................................................. 13
Questions .............................................................................................................. 13
2. Standard Error ............................................................................................................. 17
Discussion ............................................................................................................. 17
Standard Error (stderr) ..................................................................................... 17
Redirecting stderr ........................................................................................... 18
Combining stdout and stderr: Old School ............................................................ 19
Combining stdout and stderr: New School ........................................................... 20
Summary ...................................................................................................... 20
Examples .............................................................................................................. 20
Example 1. Using /dev/null to filter out stderr ....................................................... 20
Online Exercises .................................................................................................... 21
Specification .................................................................................................. 21
Deliverables ................................................................................................... 22
Questions .............................................................................................................. 22
3. Pipes .......................................................................................................................... 26
Discussion ............................................................................................................. 26
Pipes ............................................................................................................ 26
Filtering output using grep ............................................................................... 27
Pipes and stderr .............................................................................................. 27
Commands as filters ........................................................................................ 28
Examples .............................................................................................................. 28
Example 1. Listing Processes by Name ................................................................ 28
Example 2. Searching Command History Efficiently .............................................. 29
Example 3. Unix philosophy: Simple Tools that Work Well Together ........................ 29
Online Exercises .................................................................................................... 31
Specification .................................................................................................. 32
Deliverables ................................................................................................... 32
Clean Up ...................................................................................................... 32
Questions .............................................................................................................. 3

8.The Bash Shell.pdf


essing Tools
2

Table of Contents
1. Text Encoding and Word Counting ................................................................................... 6
Discussion .............................................................................................................. 6
Files .............................................................................................................. 6
What are Files? ........................................................................................ 6
What is a Byte? ....................................................................................... 7
Data Encoding ......................................................................................... 7
Text Encoding ................................................................................................. 7
ASCII .................................................................................................... 7
ISO 8859 and Other Character Sets ............................................................. 9
Unicode (UCS) ........................................................................................ 9
Unicode Transformation Format (UTF-8) .................................................... 10
Text Encoding and the Open Source Community .......................................... 10
Internationalization (i18n) ................................................................................ 11
The LANG environment variable ............................................................... 11
Do I Really Have to Know All of This? ...................................................... 12
Revisiting cat, head, and tail ............................................................................. 13
Revisiting cat ......................................................................................... 13
Revisiting head and tail ........................................................................... 13
The wc (Word Count) Command ....................................................................... 14
Counting Made Easy ............................................................................... 14
How To Recognize A Real Character ......................................................... 15
So, What Is A Word? .............................................................................. 15
Examples .............................................................................................................. 15
Example 1. Counting Characters ......................................................................... 15
Example 2. Invisible Characters Are Important, Too ............................................... 15
Example 3. What's My Line? ............................................................................. 16
Example 4. I Want It All .................................................................................. 16
Example 5. Linux, Dos, and Macintosh Files ........................................................ 16
Example 6. Counting Users ............................................................................... 16
Example 7. Counting Processes .......................................................................... 17
Online Exercises .................................................................................................... 17
Specification .................................................................................................. 17
Deliverables ................................................................................................... 18
Hints ............................................................................................................ 18
Questions .............................................................................................................. 19
2. Finding Text: grep ....................................................................................................... 22
Discussion ............................................................................................................. 22
Searching Text File Contents using grep ............................................................. 22
Show All Occurrences of a String in a File .......................................................... 23
Searching in Several Files at Once ..................................................................... 23
Searching Directories Recursively ...................................................................... 24
Inverting grep ................................................................................................ 24
Getting Line Numbers ..................................................................................... 25
Limiting Matching to Whole Words ................................................................... 25
Ignoring Case ................................................................................................ 25
Examples .............................................................................................................. 26
Example 1. Finding Simple Character Strings ....................................................... 26
Example 2. In That Case ................................................................................... 26
Example 3. Matching Whole Words .................................................................... 26
Example 4. Combining grep and xargs ................................................................ 27
Online Exercises .................................................................................................... 28
String Processing Tools
3
Specification .................................................................................................. 28
Deliverables ................................................................................................... 28
Questions .............................................................................................................. 29
3. Introduction to Regular Expressions ................................................................................ 32
Discussion ............................................................................................................. 32
Introducing Regular Expressions ....................................................................... 32
Regular Expressions, Extended Regular Expressions, and the grep Command ............. 34
Anatomy of a Regular Expression ...................................................................... 34
Taking Literals Literally .................................................................................. 35
Wildcards ...................................................................................................... 35
The "dot" wildcard ................................................................................. 35
Bracket Expressions: Ranges of Literal Characters ........................................ 35
Range Expressions vs. Character Classes: Old School and New School .............. 36
Common Modifier Characters ........................................................................... 37
Anchored Searches ......................................................................................... 38
Coming to Terms with Regex Grouping .............................................................. 38
Escaping Meta-Characters ................................................................................ 39
Summary of Linux Regular Expression Syntax ..................................................... 39
Regular Expressions are NOT File Globbing ........................................................ 40
Where to Find More Information About Regular Expressions .................................. 41
Examples .............................................................................................................. 41
Example 1. Literal Searches .............................................................................. 41
Example 2. Range Expressions ........................................................................... 41
Example 3. Regular Expression Modifiers ............................................................ 42
Example 4. Anchored Searches .......................................................................... 42
Example 5. Regular Expression Term Grouping .................................................... 43
Example 6. Is elvis in the House? ....................................................................... 43
Example 7. Searching for Telephone Numbers ...................................................... 44
Online Exercises .................................................................................................... 45
Specification .................................................................................................. 46
Deliverables ................................................................................................... 46
Questions .............................................................................................................. 47
4. Everything Sorting: sort and uniq .................................................................................... 50
Discussion ............................................................................................................. 50
The sort Command ......................................................................................... 50
Basic Sorting ......................................................................................... 50
Modifying the Sort Order ......................................................................... 50
Specifying Sort Keys ............................................................................... 52
The uniq Command ........................................................................................ 54
Reducing Data to Unique Entries ............................................................... 55
Counting Instances of Data ....................................................................... 56
Identifying Unique or Repeated Data with uniq ............................................ 56
Examples .............................................................................................................. 57
Example 1. Sorting the Output of ps aux .............................................................. 57
Example 2. Using sort and uniq to Collect Information on Running Processes .............. 58
Online Exercises .................................................................................................... 59
Specification .................................................................................................. 60
Deliverables ................................................................................................... 61
Questions .............................................................................................................. 62
5. Extracting and Assembling Text: cut and paste .................................................................. 66
Discussion ............................................................................................................. 66
The cut Command .......................................................................................... 66
Extracting Text with cut .......................................................................... 66
Extracting text by Character Position with cut -c ........................................... 67
String Processing Tools
4
Extracting Fields of Text with cut -f .......................................................... 68
Extracting Text by Byte Position with cut -b ................................................ 69
The paste Command ....................................................................................... 69
Examples .............................................................................................................. 70
Example 1. Handling Free-Format Records ........................................................... 70
Example 2. Living With Fixed-Format Records ..................................................... 70
Example 3. Using (and Misusing) a Space as a Delimiter ........................................ 71
Example 4. Examples of Pasting ........................................................................ 71
Online Exercises .................................................................................................... 72
Specification .................................................................................................. 72
Deliverables ................................................................................................... 73
Questions .............................................................................................................. 74
6. Tracking differences: diff .............................................................................................. 78
Discussion ............................................................................................................. 78
The diff Command ......................................................................................... 78
Output Formats for the diff Command ................................................................ 79
How diff Interprets Arguments .......................................................................... 82
Customizing diff to be Less Picky ..................................................................... 82
Recursive diff's .............................................................................................. 83
Examples .............................................................................................................. 85
Example 1. Using diff to Examine New Configuration Files ..................................... 85
Example 2. Using diff to Examine Recent Changes to /etc/passwd ............................. 85
Example 3. Creating a Patch .............................................................................. 86
Online Exercises .................................................................................................... 86
Specification .................................................................................................. 86
Deliverables ................................................................................................... 87
Questions .............................................................................................................. 87
7. Translating Text: tr ...................................................................................................... 91
Discussion ............................................................................................................. 91
The tr Command ............................................................................................ 91
Character Specification .................................................................................... 91
Using tr to Translate Characters ........................................................................ 92
Using tr to Delete Characters ............................................................................ 93
Using tr to Squeeze Characters ......................................................................... 93
Complementing Sets ....................................................................................... 94
One Final Caution: Avoid File Globbing! ............................................................ 94
Examples .............................................................................................................. 94
Example 1. Using tr to Clean Up the df Command ................................................. 94
Example 2. Using tr to Convert Dos Text Files to Unix ........................................... 95
Example 3. Using tr to Count Word Frequencies This example is inspired by a similar
example found in the coreutils info page (info coreutils). ......................................... 96
Example 4. Rot13 ............................................................................................ 97
Online Exercises .................................................................................................... 97
Specification .................................................................................................. 97
Deliverables ................................................................................................... 98
Questions .............................................................................................................. 98
8. Spell Checking: aspell ................................................................................................. 102
Discussion ........................................................................................................... 102
Using aspell ................................................................................................. 102
Performing an Interactive Spell Check .............................................................. 103
Performing a Non-interactive Spell Check ......................................................... 104
Managing the Personal Dictionary .................................................................... 105
Examples ............................................................................................................. 105
Example 1. Adding Service Names to aspell's Personal Dictionary ........................... 105
String Processing Tools
5
Online Exercises ................................................................................................... 106
Setup .......................................................................................................... 106
Specification ................................................................................................ 106
Deliverables ................................................................................................. 107
Questions ............................................................................................................ 107
9. Formatting Text (fmt) and Splitting Files (split) ............................................................... 110
Discussion ........................................................................................................... 110
The fmt Command ........................................................................................ 110
Motivation for the fmt Command ............................................................. 110
Rewrapping Text with the fmt Command .................................................. 113
fmt Command Syntax ............................................................................ 113
Formatting to a Specific Width ................................................................ 113
Formatting Text with a Prefix ................................................................. 114
The split Command ....................................................................................... 115
Dividing files with the split Command ...................................................... 115
split Command Syntax ........................................................................... 115
Splitting Standard In .............................................................................. 116
Examples ............................................................................................................. 116
Example 1. Using fmt to Clean Email ................................................................ 116
Example 2. Using "String Processing" Tools to Manipulate Binary Data ................... 117
Online Exercises ................................................................................................... 120
Specification ................................................................................................ 120
Deliverables ................................................................................................. 120
Questions ............................................................................................................ 12

9.Managing Processes.pdf
1. An Introduction to Processes ........................................................................................... 5
Discussion .............................................................................................................. 5
Processes are How Things Get Done ................................................................... 5
What is a Process? ........................................................................................... 5
Viewing Processes with the ps Command ............................................................. 9
Process Selection .................................................................................... 10
Output Selection ..................................................................................... 10
Oddities of the ps Command .................................................................... 10
Monitoring Processes with the top Command ....................................................... 11
Monitoring Processes with the gnome-system-monitor Application ........................... 12
Locating processes with the pgrep Command. ...................................................... 14
Examples .............................................................................................................. 15
Example 1. Viewing All Processes with the "User Oriented" Format .......................... 15
Example 2. Viewing A User's Processes with the "Long" Format .............................. 15
Example 3. Viewing A Particular Command with the "job oriented" Format ................ 16
Example 4. Viewing Processes with a Custom Format ............................................ 16
Online Exercises .................................................................................................... 17
Specification .................................................................................................. 17
Deliverables ................................................................................................... 18
Questions .............................................................................................................. 18
2. Process States .............................................................................................................. 21
Discussion ............................................................................................................. 21
A Process's Life Cycle .................................................................................... 21
How Processes are Started ....................................................................... 21
The Lineage of Processes (and the pstree Command) ..................................... 23
How a Process Dies ................................................................................ 24
The 5 Process States ....................................................................................... 24
Viewing Process States .................................................................................... 26
Examples .............................................................................................................. 26
Example 1. Identifying Process States ................................................................. 26
Online Exercises .................................................................................................... 27
Specification .................................................................................................. 27
Deliverables ................................................................................................... 28
Questions .............................................................................................................. 28
3. Process Scheduling: nice and renice ................................................................................ 31
Discussion ............................................................................................................. 31
Process Scheduling Nomenclature ...................................................................... 31
Process Scheduling, in Essence ......................................................................... 31
Process Priorities .................................................................................... 32
Process Niceness .................................................................................... 32
Changing a Process's Niceness .......................................................................... 32
Using nice to Start a low Priority Command ................................................ 33
Using renice to Alter a Running Process ..................................................... 33
Using top to Renice a Process ................................................................... 34
Making Processes Greedier ....................................................................... 34
Examples .............................................................................................................. 35
Example 1. Viewing Priorities ............................................................................ 35
Example 2. Changing Priorities with renice .......................................................... 35
Online Exercises .................................................................................................... 36
Specification .................................................................................................. 36
Deliverables ................................................................................................... 36
Managing Processes
3
Cleaning Up .................................................................................................. 36
Questions .............................................................................................................. 36
4. Sending Signals ........................................................................................................... 40
Discussion ............................................................................................................. 40
Signals ......................................................................................................... 40
Why Are Signals Sent? .................................................................................... 41
Sending Signals: the kill Command .................................................................... 41
Receiving Signals ........................................................................................... 42
Using Signals to Terminate Processes ................................................................. 42
Alternatives to the kill Command ...................................................................... 43
The pkill Command ................................................................................ 43
The killall Command ............................................................................... 44
The System Monitor ............................................................................... 44
The top Command .................................................................................. 45
Examples .............................................................................................................. 45
Example 1. Using Signals to Terminate Processes .................................................. 45
Example 2. Using Signals to Kill Processes .......................................................... 46
Example 3. Make it Stop! ................................................................................. 46
Online Exercises .................................................................................................... 46
Specification .................................................................................................. 46
Deliverables ................................................................................................... 47
Questions .............................................................................................................. 47
5. Job Control ................................................................................................................. 50
Discussion ............................................................................................................. 50
Running Commands in the Foreground ............................................................... 50
Running Commands in the Background as Jobs .................................................... 50
Managing Multiple Jobs .................................................................................. 51
Listing Current Jobs with jobs .................................................................. 51
Killing Jobs ................................................................................................... 52
Summary ...................................................................................................... 53
Examples .............................................................................................................. 53
Example 1. Deciding to Background a Command Running in the Foreground .............. 53
Example 2. Using CTRLC to Kill a Background Job .............................................. 53
Online Exercises .................................................................................................... 54
Specification .................................................................................................. 54
Deliverables ................................................................................................... 54
Clean Up ...................................................................................................... 54
Questions .............................................................................................................. 54
6. Scheduling Delayed Tasks: at ......................................................................................... 58
Discussion ............................................................................................................. 58
Daemons ....................................................................................................... 58
The atd Daemon ............................................................................................. 58
Submitting Jobs with at ................................................................................... 59
Delaying Tasks with batch ............................................................................... 59
Summary of at Commands ............................................................................... 60
Examples .............................................................................................................. 60
Example 1. Submitting an at Job as a File ............................................................ 60
Example 2. Examining the at Spool Syntax .......................................................... 60
Online Exercises .................................................................................................... 62
Online Exercise 1. Submitting a job for Delayed Execution ..................................... 62
Specification .......................................................................................... 62
Deliverables ........................................................................................... 62
Questions .............................................................................................................. 62
7. Scheduling Periodic Tasks: cron ..................................................................................... 65
Managing Processes
4
Discussion ............................................................................................................. 65
Performing Periodic Tasks ............................................................................... 65
The cron Service ............................................................................................ 65
crontab Syntax ............................................................................................... 65
Using the crontab Command ............................................................................. 66
Editing crontab Files in Place ........................................................................... 67
Where does the output go? ............................................................................... 68
Environment Variables and cron ........................................................................ 68
Examples .............................................................................................................. 69
Example 1. Monitoring a Web Site ..................................................................... 69
Example 2. Monitoring Large Files ..................................................................... 69
Example 3. Running scripts from cron ................................................................. 70
Example 4. Printing fanmail .............................................................................. 70
Online Exercises .................................................................................................... 71
Online Exercise 1. Monitoring Who is on the System. ............................................ 71
Specification .......................................................................................... 71
Deliverables ........................................................................................... 71
Questions .............................................................................................................. 7

10.Network Applications.pdf
1. An Introduction to TCP/IP Networking .............................................................................. 5
Discussion .............................................................................................................. 5
Clients, Servers, and the TCP/IP Protocol ............................................................. 5
The Server .............................................................................................. 5
Sockets ........................................................................................................... 6
More about Ports ............................................................................................. 8
Well Known Services and the /etc/services File .............................................. 8
Privileged Ports ....................................................................................... 8
Determining Current TCP/IP Networking Services .................................................. 8
Using hostname to Display the Current IP Address ......................................... 8
Using the netstat Command to Display Open Ports ......................................... 8
Online Exercises .................................................................................................... 12
Specification .................................................................................................. 13
Deliverables ................................................................................................... 13
Questions .............................................................................................................. 13
2. Linux Printing ............................................................................................................. 16
Discussion ............................................................................................................. 16
Introducing CUPS .......................................................................................... 16
Print Queues .................................................................................................. 17
Browsing Available Print Queues: lpstat ............................................................. 18
Submitting and Managing Jobs: lpr, lpq,and lprm ................................................. 18
Submitting Jobs with lpr .......................................................................... 18
Monitoring Jobs with lpq ......................................................................... 19
Removing Jobs with lprm ........................................................................ 19
Alternate Front End Commands: lp and cancel ............................................. 19
The CUPS Web Interface ................................................................................. 19
Online Exercises .................................................................................................... 20
Setup ............................................................................................................ 20
Specification .................................................................................................. 20
Deliverables ................................................................................................... 21
Questions .............................................................................................................. 21
3. Managing Print Files .................................................................................................... 24
Discussion ............................................................................................................. 24
PostScript ...................................................................................................... 24
Viewing PostScript Documents with the evince Document Viewer. .......................... 24
Decorating Text for Printing with enscript ........................................................... 26
Rearranging PostScript with mpage .................................................................... 27
Converting PostScript to PDF and PDF to PostScript ............................................. 28
Rearranging PostScript with mpage .................................................................... 29
Online Exercises .................................................................................................... 30
Specification .................................................................................................. 31
Deliverables ................................................................................................... 31
Questions .............................................................................................................. 31
4. Email Overview ........................................................................................................... 34
Discussion ............................................................................................................. 34
Using Email .................................................................................................. 34
The Simple Solution ....................................................................................... 34
The MTA (Mail Transport Agent) ............................................................. 35
The MUA (Mail User Agent) .................................................................... 35
Mailbox Servers ............................................................................................. 36
POP servers ........................................................................................... 36
Network Applications
3
IMAP servers ......................................................................................... 37
Sending Mail ......................................................................................... 37
Red Hat Enterprise Linux Default Configuration ........................................... 37
Outgoing Mail Servers .................................................................................... 37
Local Delivery ............................................................................................... 38
The mail MUA .............................................................................................. 38
Sending Email with mail .......................................................................... 39
Using mail to Read Mail .......................................................................... 39
Examples .............................................................................................................. 40
Example 1. Sending mail .................................................................................. 40
Example 2. Simple Mail Transport Protocol .......................................................... 40
Online Exercises .................................................................................................... 40
Specification .................................................................................................. 40
Deliverables ................................................................................................... 41
Questions .............................................................................................................. 41
6. Network Diagnostic Applications .................................................................................... 44
Discussion ............................................................................................................. 44
Required Configuration for the Internet Protocol ................................................... 44
IP Address ............................................................................................ 44
Default Gateway ..................................................................................... 44
Nameserver ........................................................................................... 44
Determining Your IP Address(es): /sbin/ifconfig ................................................... 45
Confirming Network Interface Configuration ............................................... 45
Determining Your Default Gateway: /sbin/route .................................................... 46
Determining Your Nameserver(s) ...................................................................... 46
Static DNS Configuration: /etc/hosts ........................................................... 47
Dynamic DNS Configuration: /etc/resolv.conf .............................................. 47
Network Diagnostic Utilities ............................................................................. 47
Confirming IP Connectivity: ping .............................................................. 48
Examining Routing: /usr/sbin/traceroute ...................................................... 48
Performing DNS Queries Manually: host .................................................... 49
Examples .............................................................................................................. 49
Example 1. Diagnosing Network Difficulties ........................................................ 49
Online Exercises .................................................................................................... 51
Specification .................................................................................................. 51
Deliverables ................................................................................................... 51
Questions .............................................................................................................. 51
7. Terminal Based Web and FTP Clients ............................................................................. 55
Discussion ............................................................................................................. 55
Why Terminal Based Clients? ........................................................................... 55
Browsing Web Pages with Elinks ...................................................................... 55
Starting Elinks ....................................................................................... 55
Configuring Elinks to use a Proxy Server .................................................... 57
Fetching Web Resources with curl ..................................................................... 57
Starting curl ........................................................................................... 57
Configuring curl to use a Proxy Server ....................................................... 58
Recursively Downloading Web Resources with wget ............................................. 58
Starting wget ......................................................................................... 59
Configuring wget to use a Proxy Server ...................................................... 60
Examples .............................................................................................................. 60
Example 1. Using terminal based file transfer utilities ............................................. 60
Online Exercises .................................................................................................... 61
Set Up .......................................................................................................... 61
Specification .................................................................................................. 61
Network Applications
4
Deliverables ................................................................................................... 62
Questions .............................................................................................................. 62
8. Remote Shell Commands .............................................................................................. 65
Discussion ............................................................................................................. 65
The Original Remote Shell: rsh and Rhosts Authentication ..................................... 65
Remote Shells with rsh ............................................................................ 65
Rhosts Authentication: ~/.rhosts ................................................................ 66
The Secure Shell ............................................................................................ 66
Secure Shell Public Key Authentication .............................................................. 67
Generating a Public-Private Key Pair: ssh-keygen ......................................... 67
Allowing Account Access: ~/.ssh/authorized_keys ........................................ 67
Public Key Authentication Details ............................................................. 68
Transferring Files Securely and Easily: scp .......................................................... 70
Secure Shell Host Authentication ....................................................................... 71
Examples .............................................................................................................. 72
Example 1. Accessing a Remote Account ............................................................. 72
Example 2. Configuring Public Key Authentication ................................................ 73
Example 3. Performing Remote Backups with SSH ................................................ 73
Online Exercises .................................................................................................... 74
Specification .................................................................................................. 74
Deliverables ................................................................................................... 74
Questions .............................................................................................................. 7

11.Supplements.pdf
1. Advanced Shell Scripting ................................................................................................ 3
Discussion .............................................................................................................. 3
Shell Scripting ................................................................................................. 3
Branches: if ... then ... [else ...] fi ......................................................................... 3
Bash syntax for branches ........................................................................... 3
The test Command ................................................................................... 4
Alternate expression for test: [ expression ] ................................................... 5
Loops: for ... in ... do ... done ............................................................................. 6
Bash syntax for loops ............................................................................... 6
Examples ................................................................................................................ 7
Example 1. A Script for "Packing" Directories ........................................................ 7
Online Exercises ...................................................................................................... 9
Specification ................................................................................................... 9
Deliverables .................................................................................................... 9
Questions ................................................................................................................ 9
2. Character Encoding and Internationalization ...................................................................... 13
Files ..................................................................................................................... 13
What are Files? .............................................................................................. 13
What is a Byte? ............................................................................................. 13
Data Encoding ............................................................................................... 14
Text Encoding ....................................................................................................... 14
ASCII ........................................................................................................... 14
ISO 8859 and Other Character Sets .................................................................... 16
Unicode (UCS) .............................................................................................. 16
Unicode Transformation Format (UTF-8) ............................................................ 17
Text Encoding and the Open Source Community .................................................. 17
Internationalization (i18n) ........................................................................................ 18
The LANG environment variable ....................................................................... 18
Do I Really Have to Know All of This? ............................................................. 19
3. The RPM Package Manager ........................................................................................... 21
Discussion ............................................................................................................. 21
RPM: The Red Hat Package Manager ................................................................ 21
The Need for Package Management ........................................................... 21
RPM Components .......................................................................................... 21
The RPM database .................................................................................. 21
The rpm Executable ................................................................................ 22
Package Files ......................................................................................... 22
Querying the RPM database ............................................................................. 22
Formulating RPM queries ........................................................................ 22
Query Examples ..................................................................................... 23
Online Exercises .................................................................................................... 25
Specification .................................................................................................. 26
Deliverables ................................................................................................... 26
Questions .............................................................................................................. 2

You might also like