- •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 311
as the chown command. The chgrp command allows group ownership of a file to be changed independent of the permissions on the file or ownership of the file.
Mounting and Managing File Systems
4.5 Manage and navigate the Linux hierarchy (e.g., /etc, /usr, /bin, /var)
4.8 Mount and manage filesystems and devices (e.g., /mnt, /dev, du, df, mount, umount)
The Linux system administrator must daily mount and manage the file systems. This task also includes the mounting and un-mounting of devices. The administrator must determine the available resources in order to manage the file systems properly. The administrator can perform these tasks by using the tools provided by the Linux operating system.
Mount
The mount command is a powerful tool used to mount directories and devices on a Linux system. The simplest application of the mount command is to use it with no options or arguments. If the command is used on its own, it will return information similar to the following:
[user@dhcppc1 user]$ mount /dev/hda1 on / type reiserfs (rw) none on /proc type proc (rw)
none on /dev/pts type devpts (rw,mode=0620)
/mnt/cdrom on /mnt/cdrom type supermount (rw,fs=iso9660,dev=/dev/cdrom) /mnt/floppy on /mnt/floppy type supermount (rw,fs=vfat,dev=/dev/fd0) /dev/hda6 on /usr type reiserfs (rw)
/dev/hda7 on /var type reiserfs (rw)
/proc/bus/usb on /proc/bus/usb type usbdevfs (rw,devmode=0664,devgid=43)
This example shows the currently mounted devices and directories. Notice that the first device, hda1, is the primary IDE controller-master device, which contains the / or root directory. Mounts for the CD-ROM drive, FDD, /usr directory, /var directory, and USB on /proc/bus/usb are also available to the system. The mount command shows all the mounted devices on the system, and the hardware path for file systems, such as /var on partition /dev/hda7. This partition is commonly used to determine currently mounted devices and directories. The options available for the mount command are listed in Table 9-15.
312 Part IV Administration
|
Table 9-15 |
|
Options for mount |
|
|
Option |
Description |
|
|
-a |
Mount all filesystems mentioned in fstab of a given type. |
|
|
-F |
Fork off a new incarnation of mount for each device. This will perform the |
|
mounts on different devices or different NFS servers in parallel and is |
|
used in conjunction with the -a option. |
|
|
-f |
This ``fakes’’ mounting the file system by performing the mount without |
|
making the actual system call. |
|
|
-h |
Provides the help file information. |
|
|
-L label |
Mount a partition that has the specified label. |
|
|
-n |
Mount without writing information in /etc/mtab. |
|
|
-r |
Mount the file system as read-only. |
|
|
-s |
Allows incorrect or sloppy mount options rather than failing. |
|
|
-t vfstype |
Used to indicate file system type. More on this option in the -t option |
|
section. |
|
|
-u uuid |
Mount the partition that has the specified uuid and requires the file |
|
/proc/partitions, available since Linux 2.1.116. |
|
|
-V |
Display mount version. |
|
|
-v |
Use verbose mode. |
|
|
-w |
Mount the file system read/write. This is the default. |
|
|
-o argument |
Options are specified with a -o flag followed by a comma separated string |
|
of options. More on this option in the -o option section. |
|
|
These options are used to mount a device. The following is a common command, which is used to mount the diskette drive on a Linux system.
[root@dhcppc1 user]# mount -v /mnt/floppy
/mnt/floppy on /mnt/floppy type supermount (rw,fs=vfat,dev=/dev/fd0)
Notice that the file system type is listed and can be assigned by the -t option.
The -t option
The -t option is used to indicate the file system type to be mounted. This allows you to mount other types of file system formats, such as msdos and vfat for Microsoft Windows. For most types, the mount program issues a simple mount system call; no detailed knowledge of the filesystem type is required because the mount command will probe the file system. If the probe fails, then the file /etc/filesystems is checked and those file types are attempted.
Chapter 9 General Linux Administration 313
The -o option
The -o option has many available arguments that allow it to provide the mount command more flexibility, as shown in Table 9-16.
|
Table 9-16 |
|
Arguments for the -o Option |
|
|
Argument |
Description |
|
|
async |
All I/O to the file system should be done asynchronously. |
|
|
atime |
Update inode access time for each access. This is the default. |
|
|
auto |
Can be mounted with the -a option. |
|
|
defaults |
Use default options: rw, suid, dev, exec, auto, nouser, and async. |
|
|
dev |
Interpret character or block special devices on the file system. |
|
|
exec |
Permit the execution of binaries. |
|
|
noatime |
Do not update inode access times on this file system. |
|
|
noauto |
Can only be mounted explicitly. |
|
|
nodev |
Do not interpret character or block special devices on the file system. |
|
|
noexec |
Do not allow execution of any binaries on the mounted file system. |
|
|
nosuid |
Do not allow set-user-identifier or set-group-identifier bits to take effect. |
|
|
nouser |
Forbid a non-root user to mount the file system. This is the default. |
|
|
remount |
Attempt to remount an already-mounted file system. |
|
|
ro |
Mount the file system read-only. |
|
|
rw |
Mount the file system read-write. |
|
|
suid |
Allow set-user-identifier or set-group-identifier bits to take effect. |
|
|
sync |
All I/O to the file system should be done synchronously. |
|
|
user |
Allow an ordinary user to mount the file system. |
|
|
Umount
The opposite of mounting a drive is to unmount it, so that it cannot be accessed. Use the umount command to unmount a file system. If a floppy diskette drive is mounted, unmount the diskette before removing it. To perform this task, use the following umount command :
[root@dhcppc1 user]# umount -v /mnt/floppy /mnt/floppy umounted
314 Part IV Administration
The umount command uses the normal structure of umount [options] argument. The arguments are devices, directories, or -t [file system type]. The options available for the umount command are shown in Table 9-17.
|
Table 9-17 |
|
Options for umount |
|
|
Option |
Description |
|
|
-a |
Un-mount all file systems mentioned in /etc/mtab. |
|
|
-h |
Provides the help file information. |
|
|
-n |
Un-mount without writing information in /etc/mtab. |
|
|
-r |
In case umount fails attempt to mount the file system as read-only. |
|
|
-t vfstype |
Used to indicate file system type. More on this option in the -t option |
|
section. |
|
|
-V |
Display umount version. |
|
|
-v |
Use verbose mode. |
|
|
Mounted file systems
One of the main reasons for adding a new mounted file system is that the current file systems don’t provide the required resources for the users. Before adding a new file system via the mount command, however, you should view the systems that are currently being used. Linux has several ways to view this information — the most common are the du and df commands.
The du command
The du command is used to summarize disk usage of each file and recursively for directories. This command provides an extensive list of all the files and their usage of storage space. You may use the du command to determine the space used on a diskette as shown in the following:
[root@dhcppc1 floppy]# ls picture.bmp* [root@dhcppc1 floppy]# du 769 .
The picture file uses 769 kilobytes of the space on the diskette. The available options for the du command are shown in Table 9-18.
Chapter 9 General Linux Administration 315
|
|
Table 9-18 |
|
|
Options for du |
|
|
|
Option |
Description |
|
|
|
|
-a |
--all |
Write counts for all files, not just directories. |
|
|
|
--block-size=SIZE |
Use SIZE-byte blocks. |
|
|
|
|
-b |
--bytes |
Print size in byte. |
|
|
|
-c |
--total |
Provide a grand total. |
|
|
|
-D |
--dereference-args |
De-reference PATHs when symbolic link. |
|
|
|
-h |
--human-readable |
Print sizes in human readable format, such as M for MB. |
|
|
|
-H |
--si |
Print sizes in human readable format but uses powers of |
|
|
1000 instead of 1024, which the -h option uses. |
|
|
|
-k |
--block-size=<size> |
Used to assign the block size, normally 1024 but maybe |
|
|
assigned 512 or 256 and so on. |
|
|
|
-l |
--count-links |
Count sizes many times if hard linked. |
|
|
|
-L |
--dereference |
De-reference all symbolic links. |
|
|
|
-m |
--megabytes |
Sets block-size=1048576. |
|
|
|
-S |
--separate-dirs |
Do not include size of subdirectories. |
|
|
|
-s |
--summarize |
Display only a total for each argument. |
|
|
|
-x |
--one-file-system |
Skip directories on different file systems. |
|
|
|
-X FILE --exclude-from=FILE |
Exclude files that match any pattern in FILE. |
|
|
|
|
--exclude=PAT |
Exclude files that match PAT. |
|
|
|
|
--max-depth=N |
Print the total for a directory (or file, with --all) only if it is N |
|
|
|
or fewer levels below the command line argument. |
|
|
|
--help |
Provide help with the program. |
|
|
|
|
--version |
Provides version information about the program. |
|
|
|
|
You can use the du command to estimate the free space used in the directory, as shown in the following.
[root@dhcppc1 /]# du /home/user
0/home/user/tmp
0/home/user/.kde/share/apps/RecentDocuments
0/home/user/.kde/share/apps/konqiconview/kpartplugins
316 Part IV Administration
1/home/user/.kde/share/apps/konqiconview
8/home/user/.kde/share/apps/konqueror/dirtree/remote/
8/home/user/.kde/share/apps/konqueror/dirtree/remote/
25 |
/home/user/.kde/share/apps/konqueror/dirtree/remote |
46 |
/home/user/.kde/share/apps/konqueror/dirtree |
62 |
/home/user/.kde/share/apps/konqueror |
64 |
/home/user/.kde/share/apps |
4/home/user/.kde/share/fonts/override
5/home/user/.kde/share/fonts
0/home/user/.kde/share/icons/favicons
1/home/user/.kde/share/icons
28 |
/home/user/.kde/share/config |
99 |
/home/user/.kde/share |
8 |
/home/user/.kde/Autostart |
108 |
/home/user/.kde |
16 |
/home/user/.netscape/cache |
4/home/user/.netscape/xover-cache/host-localhost
5/home/user/.netscape/xover-cache
0/home/user/.netscape/archive
467 /home/user/.netscape
0/home/user/mydir
4/home/user/Desktop/Trash
57 /home/user/Desktop
0/home/user/nsmail
0/home/user/.bluefish/projects 5 /home/user/.bluefish
3764 /home/user
Although the du command is capable of much more, it is ideal for determining the file usage in a single directory, such as how much space and which files are using what space in a user’s home directory.
The df comand
The df command is similar to the du command but provides information about the amount of disk space available on the file system. The following is an example of the information provided by the df command:
[root@dhcppc1 /]# df -m |
|
|
|
||
Filesystem 1M-blocks Used |
Available Use% Mounted on |
||||
/dev/hda1 |
248 |
77 |
171 |
31% |
/ |
/dev/hda6 |
913 |
687 |
226 |
75% |
/usr |
/dev/hda7 |
453 |
59 |
394 |
13% |
/var |
The additional options available to the df command are shown in Table 9-19.
Chapter 9 General Linux Administration 317
|
|
Table 9-19 |
|
|
Options for df |
|
|
|
Option |
Description |
|
|
|
|
-a |
--all |
Include file systems having 0 blocks. |
|
|
|
--block-size=SIZE |
Use SIZE-byte blocks. |
|
|
|
|
-h |
--human-readable |
Print sizes in human readable format, such as M for MB. |
|
|
|
-H |
--si |
Print sizes in human readable format but uses powers of |
|
|
1000 instead of 1024, which the -h option uses. |
|
|
|
-i |
|
List inode information instead of block usage. |
|
|
|
-k |
--block-size=<size> |
Used to assign the block size, normally 1024 but maybe |
|
|
assigned 512 or 256 and so on. |
|
|
|
-l |
--local |
Used to limit listing to local file systems. |
|
|
|
-m |
--megabytes |
Sets block-size=1048576. |
|
|
|
--no-sync |
Do not invoke sync before getting usage info, the default. |
|
|
|
|
-p |
--portability |
Use the POSIX output format. |
|
|
|
--sync |
Invoke sync before getting usage info. |
|
|
|
|
-t |
--type=TYPE |
Limit the listing to file systems of type TYPE. |
|
|
|
-T |
--print-type |
Print the file system type. |
|
|
|
-x |
--exclude-type=TYPE |
Limit the listing to file systems not of type TYPE. |
|
|
|
-v |
|
Ignored. |
|
|
|
--help |
Provide help with the program. |
|
|
|
|
--version |
Provides version information about the program. |
|
|
|
|
The ability to easily check usage of the created partitions with the df command is a valuable tool for anyone using the Linux system.
Most current systems have plenty of disk space, but you can use the df command to verify the current usage of that space displayed by percentage of used space.