- •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 9 General Linux Administration 299
Use the groupdel command to remove a group of users. This command is used with the group name in order to remove a group from the Linux system. This command can only be used if the group exists, and you must manually check all files to verify that no files are assigned with the deleted group name as the file group ID. Finally, the primary group may not be removed until all users are removed from the group. This command writes to the following files:
/etc/group: Contains group account information
/etc/gshadow: Contains secure group account information
Getting Around Linux
You must be able to navigate and manage the Linux hierarchy, set file and directory permissions, and mount and un-mount file systems and devices. The following sections detail the Linux directory hierarchy and where important files can be found, and also the common commands used to traverse these directories.
Navigating Linux
4.5 Manage and navigate the Linux hierarchy (e.g., /etc, /usr, /bin, /var)
The Linux system uses a hierarchical file system structure, meaning that the system has a primary directory (/ or root) and sub-directories that are used to manage the files. When a user logs in, the system places the user in a default directory, which is usually the user’s home directory. Each directory can be referred to by using an exact path name. Because the Linux system is a hierarchy, any user (including root) can verify the directory that they are currently using.
To see what your current directory is, use the command pwd or print working directory. This command displays the current working directory. Therefore, when a user logs in, the most common reply to the pwd command is /home/<username>, where <username> is the logged-in user. After the current directory is known, the user can move to the desired directory. To move from directory to directory, use the cd (change directory) command.
The cd command is mainly used to move from directory to directory by using the syntax, cd </directory>. Use the cd command to change the current working directory to one directory level up. For example, use the cd command in the /home/ user directory to change the current working directory to /home. To move back to the user directory, use the cd /user command or just cd user. Note that the command without the forward slash “/” will only work for directories located under the
current one. Another navigation method is to use the cd command with the full directory path of the desired directory, for example, cd /home/user/files/documents.
300 Part IV Administration
See Chapter 4 for more information on common Linux directories and their normal contents.
Common file and directory commands
4.6 Manage and navigate the standard Linux file system (e.g., mv, mkdir, ls, rm)
After choosing the working directory, the user must know how to use common file and directory commands. These commands can be used to list, copy, move, delete, and create files and directories on the Linux system.
The ls command
To list files on a Linux system, use the ls command. The ls command employs the options shown in Table 9-6.
|
Table 9-6 |
|
Options for ls |
|
|
Option |
Description |
|
|
-a |
List all entries including all those normally not displayed. |
|
|
-A |
List all entries including all those normally not displayed except |
|
the working and parent directories. |
|
|
-b |
Forces the printing of non-printable characters in the octal \ddd |
|
notation. |
|
|
-B |
Ignore backup or do not list files ending with the ~. |
|
|
-c |
Uses the time of last modification of the i-node for sorting or |
|
printing. |
|
|
-C |
Multi-column output that is the default output method. This |
|
method sorts down the columns. |
|
|
--color[=WHEN] |
Used to supply color to file types, where [=WHEN] is auto, |
|
always, or never. |
|
|
-d |
List only the name of a directory not the contents — useful with |
|
the -l option to return directory status. |
|
|
-D |
Used to generate output designed for Emacs’ dired mode. |
|
|
-f |
Force each argument to be interpreted as a directory and list the |
|
name found in each slot. This option turns off -l, -t, -s, and -r |
|
options and turns on -a option. |
Chapter 9 General Linux Administration 301
Option |
Description |
|
|
-F |
Used to identify the contents of a directory, returning (/) for |
|
directories, (>) for doors, (*) for executable files, (|) for FIFO’s, |
|
(@) for symbolic links and (=) for AF_UNIX address family |
|
sockets. |
-g |
List in long format, giving mode, ACL indication, number of links, |
|
group, size in bytes, and time of last modification for each file, |
|
often ignored in newer version. |
|
|
-G |
Don’t display group information. |
|
|
-h |
Print sizes in human readable format. |
|
|
-H |
Supplies the block sizes for each entry but uses powers of 1000 |
|
not 1024 |
|
|
-i |
Prints the i-node number for each file. |
|
|
-l |
Use a long listing format. |
|
|
-L |
List the file or directory the link references rather than the |
|
symbolic links. |
|
|
-m |
List the files across the page separated by commas. |
|
|
-n |
List in long format, giving mode, ACL indication, number of links, |
|
owner’s UID, group’s GID, size in bytes, and time of last |
|
modification for each file. |
|
|
-N |
Used to print raw entry names. |
|
|
-o |
List in long format, giving mode, ACL indication, number of links, |
|
owner, size in bytes, and time of last modification for each file. |
|
|
-p |
Places a (/) after each listing of a directory, some |
|
implementations include the -F features. |
|
|
-q |
Force printing of non-printable characters in file names as a |
|
question mark (?). |
|
|
-Q |
Used to enclose entry names in double quotes. |
|
|
--quoting-style=WORD |
Use quoting style WORD for entry names: literal, locale, shell, |
|
shell-always, c, escape. |
|
|
-r |
Reverses the order of sort to supply reverse alphabetic or date list. |
|
|
-R |
Recursively list subdirectories encountered. |
|
|
-s |
Supplies the block sizes for each entry. |
|
|
-S |
Sort by file size. |
|
|
-t |
Sorts by time stamp instead of name. |
|
|
-T --tabsize=COLS |
Assume tab stops at each COLS instead of 8. |
Continued
302 Part IV Administration
|
Table 9-6 (continued) |
|
|
Option |
Description |
|
|
-u |
Used with the -t option to sort by last time accessed instead of |
|
the default last modified. |
|
|
-U |
Don’t sort, just display entries in directory order. |
|
|
-v |
Sorts by version. |
|
|
-w --width=COLS |
Assume screen width supplied instead of current value. |
|
|
-x |
Multi-column output with entries sorted across the page. |
|
|
-X |
Sort alphabetically by entry extension. |
|
|
-1 |
Print one entry per line of output. |
|
|
--help |
Provide help with the program. |
|
|
--version |
Provides version information about the program. |
|
|
Use the ls command to view the files and directories of a Linux system. For example:
$ ls /boot |
|
|
System.map@ |
chain.b |
map |
System.map-2.4.3-20mdk config@ |
message |
|
boot-graphic.b |
config-2.4.3-20mdk message-graphic |
|
boot-menu.b |
grub/ |
os2_d.b |
boot-text.b |
initrd-2.4.3-20mdk.img us.klt |
|
boot.0300 |
initrd.img@ |
vmlinuz@ |
boot.b@ |
kernel.h |
vmlinuz-2.4.3-20mdk |
The cp command
Use the cp command to copy files and directories in the following format: cp [options] <source> <destination>. Use this command to copy a file or directory from the source to the destination. The cp command employs the options shown in Table 9-7.
|
Table 9-7 |
|
Options of cp |
|
|
Option |
Description |
|
|
-a |
Preserve links and file attributes if possible and copy directories |
|
recursively. |
|
|
-b |
Make a backup of each existing destination file. |
|
|
-d |
Preserve links. |
|
|
Chapter 9 General Linux Administration 303
Option |
Description |
|
|
-f |
Automatically remove existing destinations. |
|
|
-i |
Prompt before overwriting the destination. |
|
|
-l |
Link files instead of copying. |
|
|
-p |
Preserve file attributes if possible. |
|
|
-P |
Append source path to DIRECTORY. |
|
|
-r |
Copy recursively and treat non-directories as files. |
|
|
-R |
Directories are copied recursively. |
|
|
-s |
Create symbolic links instead of copying. |
|
|
-S --suffix=SUFFIX |
Override the default backup suffix. |
|
|
-u |
Copy only files when the source file is newer than the destination, or |
|
the destination does not exist. |
|
|
-v |
Verbose mode that explains what is being done. |
|
|
-x |
Stay on this file system. |
|
|
--help |
Provides help with the program. |
|
|
--version |
Provides version information about the program. |
|
|
The cp command can be used like this:
[user@dhcppc1 user]$ cp /home/user/myfile /tmp/ [user@dhcppc1 user]$ ls /tmp
kde-root/ ksocket-root/ mcop-user2/ mcop-user/ kde-user/ ksocket-user/ mcop-root/ myfile
Anyone who uses a file system needs the ability to copy files from one location to another. Linux provides the cp command to perform this task.
The mv command
You can move files on the Linux system by using the mv command. This command takes on the following format: mv [options] <source> <destination>. The mv command is a very capable tool for moving files in the Linux environment. The available options for the mv command are shown in Table 9-8.
304 Part IV Administration
|
Table 9-8 |
|
Options of mv |
|
|
Option |
Description |
|
|
-b |
Make a backup of each existing file before removal. |
|
|
-f |
Automatically remove existing destinations. |
|
|
-i |
Prompt before overwriting the destination. |
|
|
-S --suffix=SUFFIX |
Override the default backup suffix. |
|
|
-u |
Move only older or brand new non-directories. |
|
|
-v |
Verbose mode that explains what is being done. |
|
|
-V --version-control=WORD |
Override the normal version control. |
|
|
--help |
Provide help with the program. |
|
|
--version |
Provide version information about the program. |
|
|
The mv command can be used as follows:
[user@dhcppc1 user]$ mv /tmp/myfile /home/user/ [user@dhcppc1 user]$ ls /home/user
Desktop/ myfile nsmail/ tmp/
The rm command
Use the rm command to delete files on a Linux system. This command uses the following format: rm [option] <file>. Use this command with the options shown in Table 9-9.
|
|
Table 9-9 |
|
|
Options of rm |
|
|
|
Option |
Description |
|
|
|
|
-d |
|
Unlink directory, even if non-empty. |
|
|
|
-f |
|
Ignore nonexistent files. |
|
|
|
-i |
|
Prompt before any removal. |
|
|
|
-r |
-R --recursive |
Remove the contents of directories recursively. |
|
|
|
-v |
|
Verbose mode that explains what is being done. |
|
|
|
--help |
Provide help with the program. |
|
|
|
|
--version |
Provide version information about the program. |
|
|
|
|
Chapter 9 General Linux Administration 305
The rm command is used as follows:
[user@dhcppc1 user]$ rm /home/user/myfile rm: remove `myfile’? y
[user@dhcppc1 user]$ ls /home/user Desktop/ nsmail/ tmp/
The touch command
To create a file that does not exist on a Linux system, use the touch command. This command uses the following format: touch [options] <file>. This command employs the options shown in Table 9-10.
|
Table 9-10 |
|
Options of touch |
|
|
Option |
Description |
|
|
-a |
Change only the access time. |
|
|
-c |
Do not create any files. |
|
|
-d --date=STRING |
Parse STRING and use that instead of the current time when |
|
marking the file. |
|
|
-f |
A BSD option ignored in Linux but allowed. |
|
|
-m |
Change only the modification time. |
|
|
-r |
Use the files time instead of the current time. |
|
|
-t [[CC]YY]MMDDhhmm[ss] |
*STAMP [[CC]YY]MMDDhhmm[ss] used instead of current |
|
time. |
|
|
--help |
Provide help with the program. |
|
|
--version |
Provide version information about the program. |
|
|
If the touch command is used on a file that does not exist, and the -c option is not specified, the file will be created. You can also use this command to modify dates on files to reflect a different time than the data and time that is already assigned. Use this command to ensure that a file is backed up on a specific archive, or to show that the file is used before you purge old files. Finally, use the touch command to create a file where one did not previously exist, as shown by the following:
[user@dhcppc1 user]$ ls /home/user Desktop/ nsmail/ tmp/
[user@dhcppc1 user]$ touch /home/user/myfile2 [user@dhcppc1 user]$ ls /home/user
Desktop/ myfile2 nsmail/ tmp/
306 Part IV Administration
The mkdir Command
You can create a directory on a Linux system by using the mkdir command. This command is commonly used in the following format: mkdir [options] <directory name>. This command employs the options shown in Table 9-11.
|
Table 9-11 |
|
Options of mkdir |
|
|
Option |
Description |
|
|
-m, --mode=MODE |
Set permission mode (as in chmod), not rwxrwxrwx - umask. |
|
|
-p, --parents |
Make parent directories as needed. |
|
|
--verbose |
Print a message for each created directory. |
|
|
--help |
Provide help with the program. |
|
|
--version |
Provides version information about the program. |
|
|
The mkdir command looks like this:
[user@dhcppc1 user]$ ls /home/user Desktop/ myfile2 nsmail/ tmp/
[user@dhcppc1 user]$ mkdir --verbose /home/user/mydir mkdir: created directory `mydir’
[user@dhcppc1 user]$ ls /home/user Desktop/ mydir/ myfile2 nsmail/ tmp/
The rmdir Command
Use the rmdir command to remove a directory on a Linux system. This command is commonly used in the following format: rmdir [options] <directory name>.
Notice that most commands use the same format — [command] [options] [argument]. This convention is helpful for remembering the proper syntax for any command.
This command uses the options shown in Table 9-12.