- •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 8 User Environment Settings 277
#If power was restored before the shutdown kicked in, cancel it. pr:12345:powerokwait:/sbin/shutdown -c “Power Restored; Shutdown Cancelled”
#Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2
#Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6
#Run xdm in runlevel 5
#xdm is now a separate service x:5:respawn:/etc/X11/prefdm -nodaemon
The previous file shows how the INIT process sets up the system for a certain runlevel. The INIT process is used to start specific services for specific run levels and general services for every run level. In the preceding example, the default run level is indicated in the line si::sysinit:/etc/rc.d/rc.sysinit, several items run in standard run levels, and the X Window System runs in run level 5. Editing the configuration file for the INIT process can be useful to start services for a specific run level or all run levels. One of the major jobs of the inittab file is to set up the environment variable TERM, which should normally contain the name of the type of terminal, console, or display-device type to be used.
The /etc/inittab file will control the TERM environment, so be familiar with the location and format of the file.
This information is critical to any program that is screen-oriented, including editors, mailers, and remote access programs. A default TERM value is set on a per-line basis and nearly always provides all the services needed for a workstation console. However, you can edit the terminal parameters to use a different configuration depending on the needs of a user. Use the inittab file to set up user-specific TERM environment specifications when the default settings are not acceptable.
BASH
3.11 Identify the purpose and characteristics of configuration files (e.g., BASH, inittab, fstab, /etc/*)
3.12 Edit basic configuration files (e.g., BASH files, inittab, fstab)
The Bourne Again SHell (BASH), is the shell, or command language interpreter, for the GNU operating system and is standard for most Linux systems. BASH has many
278 Part III Configuration
features that allow it to perform well in the Linux environment, including command and filename completion, command line editing, history commands and events, detailed shell operational control, and aliasing. BASH is widely used because of these abilities. To verify the use of BASH on a system, use the env command to list information shown below:
bash-2.04$ env PWD=/home/bill TMPDIR=/tmp/ LC_MESSAGES=en_US REMOTEHOST=192.168.0.6 HOSTNAME=dhcppc1
NLSPATH=/usr/share/locale/%l/%N
LESSKEY=/etc/.less LESSOPEN=|/usr/bin/lesspipe.sh %s LANGUAGE=en_US:en
PS1=\s-\v\$ LESS=-MM USER=bill
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;0 1:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.b tm=01;32:*.bat=01;32:*.tar=01;31:*.tgz=01;31:*.tbz2=01;31:*.arc=01;31:*.arj=01;3 1:*.taz=01;31:*.lzh=01;31:*.lha=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31 :*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01 ;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:*.tiff=01;35:
LC_TIME=en_US MACHTYPE=i586-mandrake-linux-gnu MAIL=/var/spool/mail/bill INPUTRC=/etc/inputrc
LANG=en LC_NUMERIC=en_US TMP=/tmp/ LOGNAME=bill SHLVL=1 LC_CTYPE=en_US SHELL=/bin/bash HOSTTYPE=i586 OSTYPE=linux-gnu HISTSIZE=1000 TERM=ansi HOME=/home/bill
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games SECURE_LEVEL=3
LC_MONETARY=en_US RPM_INSTALL_LANG=en_US:en LC_COLLATE=en_US _=/usr/bin/env
Notice the line
SHELL=/bin/bash
Chapter 8 User Environment Settings 279
that sets this system to use BASH as the default shell. The configuration files for BASH are .bash_profile, .bashrc, and .bash_logout. The . bash_profile is the login initialization file for BASH. The shell is initialized in a couple of ways — one upon boot and the other interactively. Both ways look for the .bashrc file, which contains the configuration. The file is executed each time the BASH shell or any sub-shells are entered. A global file, usually located at /etc/bashrc, and a user specific file, usually located in /home/username/.bashrc, are the configurations that BASH will use. Any changes to these initialization files will take effect the next time the system is restarted, or the changes can be activated during the current session by running the initialization program. This allows the special features to
be activated.
To learn more about the features of BASH, see the MAN pages. The most common options that can be enabled are noclobber, ignoreeof, and alias. Alias is especially useful because it simplifies the use of common commands, such as adding alias cp ‘cp -i’ to allow only the cp command to be used instead of cp -i command. The home directory of each user also contains the . bash_profile and . bash_logout files. The . bash_logout file can be edited to perform tasks when a user logs out. A common addition to this file is the ability to display messages on logout. A common . bash_logout file may look like this:
# ~/.bash_logout
clear
echo “Exiting the system”
These BASH commands clear the screen and then display the message, “Exiting the system.” The . bash_profile may also be named .profile and is the BASH login initialization file, which is a script that is executed whenever a user logs in. You can also use the BASH logon initialization file to define special environmental variables used to manage the shell, and to set PATH variables for Linux to use to provide quick access to your application programs that are located in other directories. You can do this by using the following simple method:
#.bash_profile
#Get the aliases and functions if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#User specific environment and startup programs
PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
export BASH_ENV PATH unset USERNAME
280 Part III Configuration
Notice the PATH lines in the preceding example; the first path line sets the $PATH, which holds the directories searched for any command entered, and $HOME, which holds the path of the users home directory. The /bin adds the user’s bin directory to the directories searched when a command is entered. The next line sets the BASH_ENV to the user’s home directory and to that user’s . bashrc for individual configuration. Notice also the export command, which is used to export the variables to any sub-shells that may be used. By using an editor, you can customize the . bash_profile as illustrated here:
#Get the aliases and functions if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#User specific environment and startup programs
PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
MAILDIR=$HOME/nsmail
MAIL=$HOME/nsmail/Inbox
export BASH_ENV PATH unset USERNAME
The available configurations are virtually limitless — thus making BASH an excellent shell for most environments. Table 8-5 shows the location and purpose of the BASH shell configuration files.
Table 8-5
Shell Configuration Files
Shell |
File |
Function |
|
|
|
BASH |
.bash_profile |
Login initialization file |
|
|
|
BASH |
.bashrc |
Shell configuration file |
|
|
|
BASH |
.bash_logout |
Logout functions |
|
|
|
By using the files in Table 8-5, you are able to control and configure the shell environment for all users or individual users.