- •About the Author
- •Credits
- •How This Book Is Organized
- •Part I: Linux Basics
- •Part II: Installation
- •Part III: Configuration
- •Part IV: Administration
- •Part V: Maintaining the Linux System
- •How Each Chapter Is Structured
- •How to Use This Book
- •Conventions Used in This Book
- •What is Linux?
- •The origin of UNIX
- •Who started Linux?
- •Understanding Open Source
- •Understanding Closed Source
- •Understanding Artistic License
- •Is Freeware really free?
- •Is Shareware never free?
- •A comparison and contrast of licensing methods
- •The Growth of Linux
- •Linux on a Personal Computer
- •Graphical installation
- •Hardware detection
- •Graphical user interface
- •Linux limitations on the PC
- •Linux succeeds on the PC
- •Linux on workstations
- •Linux on servers
- •Summary
- •Assessment Questions
- •Scenarios
- •Answers to Chapter Questions
- •Assessment Questions
- •Scenarios
- •Linux Kernel
- •Kernel versions
- •Kernel availability
- •Linux Distributions
- •Beehive
- •BlueCat
- •Caldera OpenLinux
- •Debian
- •Corel
- •DragonLinux
- •Elfstone
- •Gentoo
- •Hard Hat Linux
- •KRUD
- •LinuxPPC
- •Mandrake
- •Phat Linux
- •Slackware
- •StormLinux
- •SuSE
- •TurboLinux
- •Yellow Dog Linux
- •Mini and Specialty Distributions
- •Astaro
- •KYZO
- •FlightLinux
- •NetMAX
- •Packages and Packaging Solutions
- •Red Hat Package Manager
- •Debian Package Management System
- •Tarball
- •Linux Resources
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Assessment Questions
- •Scenarios
- •Linux In the Real World
- •Word Processing
- •Spreadsheets and databases
- •Web browsing
- •File transfer
- •More, more, and more applications
- •The Server and DNS
- •A Linux Web server
- •Linux e-mail server
- •File servers
- •Proxy, news, and search servers
- •FTP servers
- •Firewalls
- •Determining Linux Roles and Services
- •Comparing Linux with other operating systems
- •Hardware compatibility
- •Summary
- •Assessment Questions
- •Scenarios
- •Answers to Chapter Questions
- •Assessment Questions
- •Scenarios
- •Installing Linux
- •Final Preparations for Installation
- •Verification
- •Package selection
- •Final hardware verification
- •Pre-installation partitioning planning
- •Installing Linux
- •Text or GUI installation
- •Basic setup of Linux
- •Selecting the machine type
- •Partitioning the hard disk drive
- •Installing a boot manager
- •Creating the Boot Diskette
- •Networking
- •Additional installation information
- •Accounts and passwords
- •Additional packages to install
- •GUI installation
- •Obtaining video card information
- •Configuring the X windows system
- •Selecting the windows manager or desktop environment
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Answers to Assessment Questions
- •Scenarios
- •Alternative to the GUI Installation
- •Command Line installation
- •Install the Linux system
- •Network installations of Linux
- •Review of a Linux Installation
- •Installation media
- •Initial selections
- •Installation type or class
- •Disk partitioning and formatting
- •Installing LILO
- •Network configuration
- •User accounts
- •Authentication methods
- •Package selection and installation
- •A Dual-Boot Installation of Linux
- •Linux with Microsoft Windows
- •Linux with Microsoft Windows NT and 2000
- •Linux and Solaris
- •Linux and other operating systems
- •Installing Additional Software with gzip and tar
- •Installing Additional Software with RPM
- •Removing software with RPM
- •Upgrading software with RPM
- •Query the RPM software
- •Verify the RPM software
- •Verify the package files
- •Upgrading the Kernel
- •Upgrading a Linux Kernel
- •System Log Files
- •The Final Test of the Installation
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •What is the X Window System?
- •The X Window System
- •X Client and Server communications
- •X Window Manager
- •Configuring X Window Systems
- •Custom X Window System Programs
- •Manual Configuration of the X Window System
- •Documentation
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Basic Network Services
- •TCP/IP Protocol Suite
- •Connection protocols needed
- •Other network protocols
- •Configuring Basic Network Services
- •Host name
- •IP addressing
- •DHCP
- •Netmask
- •Hardware resources
- •Routing and gateways
- •PPP, SLIP and PLIP connections
- •Server Tasks with
- •IP aliases for virtual hosts
- •Apache Web Server
- •Samba File Server
- •Home directories
- •Disk shares
- •Configuring Client Services
- •SMB/CIFS
- •NIS client configuration
- •NFS client configuration
- •Configuring Internet Services
- •Web browser
- •POP and SMTP
- •TFTP
- •SNMP
- •Remote Access
- •Rlogin
- •Telnet
- •OpenSSH
- •Documentation
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Adding Hardware
- •Memory
- •Swap
- •Adding a hard drive
- •Video and monitor
- •Printers
- •Configuration files
- •Setting environment variables
- •BASH
- •Documentation
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Basic User and Group Administration
- •What are users and groups?
- •Creating users
- •Change user information
- •Deleting users
- •Creating groups
- •Getting Around Linux
- •Navigating Linux
- •Common file and directory commands
- •Setting File and Directory Permissions
- •Mounting and Managing File Systems
- •Mount
- •Umount
- •Mounted file systems
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Multi-User Environment
- •The creation of Virtual Consoles
- •The Linux Terminal Server Project
- •Configurations for remote systems
- •Monitoring remote connections
- •Common Shell Commands
- •Basic shell scripts
- •Caution using root access
- •Navigating the GUI interface
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Linux Runlevels
- •init
- •Shutting down Linux
- •Managing Linux Services
- •Configuring Linux Printing
- •lpd daemon
- •/etc/printcap
- •Printing management
- •Using the vi Editor
- •vi operation modes
- •Editing text files
- •Using the
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Disk and File System Management
- •Repairing Partitions
- •System Automation and Scheduling
- •cron
- •Core Dumps
- •Analyzing core dumps
- •GNU Debugger
- •Managing Networking Interfaces
- •Installing System Packages and Patches
- •Compressed archive
- •Debian Package Installer
- •Slackware Package Installation
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Linux Processes
- •Core services versus non-critical services
- •Process administration
- •Process control
- •Monitoring Log Files
- •Maintaining Documentation
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Linux Security
- •Securing the Environment
- •Location
- •Environment
- •System Security
- •System/user files
- •Permissions
- •Log auditing
- •Backups
- •Linux Security Best Practices
- •Network security
- •Firewall
- •System security
- •Securing a Web server
- •Securing an FTP server
- •FTP program version
- •FTP configuration files
- •Process security
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Disaster Recovery Planning
- •Types of data
- •Frequency and Scheduling
- •Storage and media types
- •Recovering data
- •Offsite storage
- •Linux Backup Tools and Commands
- •Third party tools
- •Tape devices
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Identifying the Problem
- •Methodology and Best Practices
- •Troubleshooting Resources
- •Documentation resources
- •Internet resources
- •System Log Files
- •Tools for Log Files
- •Output to another file
- •Locating files
- •Process Configuration and Management
- •Stopping, Starting, and Restarting Processes
- •Configuration Files
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Examining the Startup Process
- •Boot process steps
- •Analyzing Boot Process Errors
- •Common Boot Problems
- •Using System Status Tools
- •File System Check
- •System Resource Commands
- •Using the System Boot Disk
- •Types of boot disks
- •Creating a boot disk
- •Creating a rescue/utility disk
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Common User Problems
- •Login problems
- •File and directory permissions
- •Printing problems
- •Mail problems
- •Software Package Problems
- •Package dependencies
- •Software and version conflicts
- •Backup and Restore Errors
- •Backup hardware
- •Backup software
- •File restore errors
- •Application Failures
- •Log files
- •Process and daemon errors
- •Web server errors
- •Telnet
- •Mail services
- •Basic Networking Troubleshooting
- •Networking connectivity
- •Network hardware problems
- •Summary
- •Assessment Questions
- •Scenarios
- •Lab Exercises
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •Mainboard Components
- •BIOS
- •System memory
- •System Resources
- •I/O addresses
- •Direct memory access
- •Laptop Considerations
- •PCMCIA
- •Linux Peripheral Configuration
- •Installing and Configuring SCSI Devices
- •SCSI definitions
- •SCSI technologies
- •SCSI cabling and termination
- •SCSI device configuration
- •Linux SCSI devices
- •ATA/IDE Devices
- •IDE drive configuration
- •Linux ATA/IDE Drive configuration
- •Linux Support for Other Devices
- •IEEE 1394 (Firewire)
- •Summary
- •Assessment Questions
- •Scenarios
- •Answers to Chapter Questions
- •Chapter Pre-test
- •Assessment Questions
- •Scenarios
- •What’s on the CD-ROM
- •System Requirements
- •Using the CD with Microsoft Windows
- •Using the CD with Linux
- •Microsoft Windows applications
- •Linux applications
- •Troubleshooting
- •Sample Exam
- •Exam Questions
- •Exam Answers
- •Taking a CompTIA Exam
- •How to register for an exam
- •What to expect at the testing center
- •Your exam results
- •If you don’t receive a passing score
- •About the Linux + Exam
- •Preparing for the Linux+ Exam
- •For More Information
- •Preamble
- •No Warranty
- •Glossary
- •Index
Chapter 10 Linux Terminals and Shells 341
Option |
Description |
|
|
--numeric-ports |
Shows numerical port numbers but does not affect the resolution |
|
of host or user names. |
|
|
--numeric-users |
Shows numerical user IDs but does not affect the resolution of |
|
host or port names. |
|
|
-o --timers |
Includes information related to networking timers. |
|
|
-p --program |
Shows the PID and name of the program to which each socket |
|
belongs. |
|
|
-r --route |
Displays the kernel routing tables. |
|
|
-s --statistics |
Displays summary statistics for each protocol. |
|
|
-v --verbose |
Verbose mode that explains what is being done. |
|
|
Netstat is a powerful tool that is used by experienced network administrators, but can also be used as a basic tool to see active connections to a system.
The use of any Linux command, such as netstat, requires the use of the proper syntax. Know the basic structure of the command and the switches.
Common Shell Commands
4.10 Use common shell commands and expressions.
Basic tools are built into the shells, which are started as the environment when a user or administrator logs in to a Linux system. The most common shell for Linux is Bash or Bourne Again SHell. Other major shell programs used for Linux are Public Domain Korn Shell (PDKSH), the TCSH shell, and the Z-shell.
See Chapter 8 for more information on shell programs.
Bash is an sh-compatible command language interpreter, which is intended to conform with the IEEE POSIX Shell and Tools specification. Bash also incorporates useful features from the Korn and C shells (ksh and csh). The following are the configuration files for Bash:
/bin/bash: The bash executable
/etc/profile: The system wide initialization file for login shells
~/.bash_profile: The personal initialization file for login shells
342 Part IV Administration
~/.bashrc: The individual per-interactive-shell startup file
~/.bash_logout: The login shell cleanup file that executed when the shell exits
~/.inputrc: Individual read line initialization file
Instructions for the Bash shell are very large and complex — in fact, the MAN page contains over 5000 lines of text, and thus covering this topic would require another book. Some of the most common and useful tools included in the shell are shown in Table 10-2.
Table 10-2
Bash Shell Commands and Tools Used
Option |
Description |
|
|
Arrow up and down |
Scrolls through recent commands used. |
|
|
| |
Uses the format command1 | command2 and places the |
|
output of command1 and inputs into command2. |
|
|
&& |
Uses the format command1 && command2 and |
|
command2 is executed if, and only if, command1 returns |
|
an exit status of zero. |
|
|
|| |
Uses the format command1 || command2 and command2 |
|
is executed if and only if command1 returns a non-zero exit |
|
status. |
|
|
alias |
Alias with no arguments or with the -p option prints the list |
|
of aliases in the form alias name=value on standard output. |
|
|
bg [jobspec] |
Resumes the suspended job jobspec in the background, as |
|
if it had been started with &. (background=bg) |
|
|
break [n] |
Exit from within a for, while, until, or select loop. |
|
|
cd |
Changes the current directory to dir. |
|
|
continue [n] |
Resumes the next iteration of the enclosing for, while, until, |
|
or select loop. |
|
|
cut [options][FILE...] |
Prints selected parts of lines from each FILE to standard |
|
output. |
|
|
dirs |
This displays the list of currently remembered directories. |
|
|
echo |
Outputs the args, separated by spaces, followed by a new |
|
line. |
|
|
enable |
Enables and disables built-in shell commands. |
|
|
Chapter 10 Linux Terminals and Shells 343
Option |
Description |
|
|
exit [n] |
Causes the shell to exit with a status of n. |
|
|
find [path...] [expression] |
Searches the directory tree rooted at each given file name |
|
by evaluating the given expression from left to right, |
|
according to the rules of precedence until the outcome is |
|
known at which point find moves on to the next file name. |
|
|
fg [jobspec] |
Resumes jobspec in the foreground, and makes it the |
|
current job. (foreground=fg) |
|
|
grep [options][FILE...] |
Grep searches the named input FILE. |
|
|
help [-s] [pattern] |
Displays helpful information about built-in commands. |
|
|
history |
Displays the command history list with line numbers. |
|
|
kill [-s sigspec | -n signum | |
Sends the signal named by sigspec or signum to the |
-sigspec] [pid | jobspec] |
processes named by pid or jobspec. |
|
|
logout |
Exits a login shell. |
|
|
pwd |
Prints the absolute pathname of the current working |
|
directory. |
|
|
read |
One line is read from the standard input, and the first word |
|
is assigned to the first name, the second word to the |
|
second name, and so on, with leftover words and their |
|
intervening separators assigned to the last name. |
|
|
umask [-p] [-S] [mode] |
The user file-creation mask is set to mode. |
|
|
unalias |
Removes each name from the list of defined aliases. |
|
|
wait [n] |
Waits for the specified process and returns its termination |
|
status. |
|
|
This is by no means the definitive list of tools for Bash. With experience, you will learn more of the included shell commands and the necessary commands for each environment. These common commands can help make Linux tools — especially the history tool — easier to use for everyone.
Basic shell scripts
4.18 Program basic shell scripts using common shell commands (e.g., grep, find, cut, if)
344 Part IV Administration
You can use the common shell commands to create some very simple scripts to perform routine tasks. You can chain together a number of basic commands to perform a specific task. Here is an example of a shell script:
#!/bin/sh
# This script changes to your home directory and does a directory list
cd /home/user1 ls -al
In this simple script, all we are doing is changing to a user’s home directory, and listing the contents of that directory.
The first line identifies this as a shell script that is passed to the BASH shell program at /bin/sh. This is important to ensure that the script is run under the BASH shell and not another one such as C shell.
The second line is a comment, telling the user what the script does. All comments are preceded with a “#” mark.
The next two commands are simply BASH shell commands to change to the user home directory, and list the contents.
Here is a list of common commands that can be very useful when programming shell scripts:
grep — This command searches for a specific pattern of text in a file. This is useful for searching large amounts of text for a certain name or error message.
find — This command is similar to grep, as it searches a directory for a pattern or file that you are looking for.
cut — This command removes sections of text from lines of a file.
if — If you need to perform some type of logical decision making within a script, you would use the if command. For example:
if [ “yes” = “yes” ]; then echo “The answer is yes”
These simple examples barely scratch the surface of the many large tasks you can perform using shell scripts.