- •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 13 Process Management 411
Linux is a multi-user, multi-tasking operating system. Every time you run a program under Linux, you begin what is known as a process. A process is another
name for a program that is run by a particular user. Depending on the processing and memory resources on your particular machine, a large number of processes can run simultaneously. Linux administrators must know what processes are running on their systems, and to what extent the processes are affecting system performance. This chapter deals with the subject of how to view, manage, stop, and start these processes.
The Linux administrator must also maintain system logs. The logs can provide excellent troubleshooting information by reporting system errors, user logins, and any unusual behavior that may affect the system. This chapter shows you where to find the different types of logs and how to interpret their data. Finally, this chapter also discusses the importance of documenting and maintaining the information on your Linux system and its performance.
Linux Processes
At any given time, your Linux system is constantly running several processes. These processes run concurrently and are simultaneously executed by the CPU. They also don’t interfere with each other; for example, if one process crashes or ends abnormally, it won’t affect any other process in the system. Some processes can spawn other processes, which are called child processes. If you stop a child process, the parent process will continue. However, if you stop the parent process, each child process is also stopped. A process uses several system resources when running, including the following:
CPU: Runs the instructions for the process.
Memory: Holds the process and any data that it is using.
File Systems: Allows access to required physical files, and also allocates temporary storage for processing.
Physical Devices: Allows processes to access physical devices, such as monitors, hard drives, and printers.
The system tracks each process for its usage of these resources, and allocates these resources as needed to the process that needs them the most. Some processes are given priority over others, while the other processes must “wait their turn” to use the CPU.
A process can be in one of the following states:
Running: The process is currently assigned to a CPU and running.
Ready: The process is waiting to be assigned to a CPU.
412 Part V Maintaining the Linux System
Waiting: The process is waiting for a particular resource to become available.
Zombie: The process has stopped but is still consuming resources; also often referred to as a “dead” process.
Stopped: The process is in a stopped state.
The CPU uses a special identification number called a PID, or Process ID, which tracks each process. This number allows the administrator to more easily differentiate between processes while managing the system. The PID can also be used in conjunction with several commands to change the state of a process.
Core services versus non-critical services
5.6 Differentiate core services from non-critical services (e.g., ps, PID, PPID, init, timer)
Several core processes are integral to the Linux system because they run critical programs that the Linux kernel needs in order to function properly. These processes are run at boot time, and are usually referred to as “daemons.”
For the exam, be careful to differentiate the core services from regular application and user processes.
Init
The most important service in a Linux system is provided by init. Init starts when the system boots, and continues the boot process by performing various startup jobs, such as checking and mounting file systems, and starting services and daemons. When the system is shut down, the init process stops all other processes, unmounts the file systems, and halts the system.
All processes are spawned from init. Many Linux startup services and daemons are spawned from the init process. The command pstree gives you a list of all the processes in a “tree” format, so you can easily discern the parent and child processes. This is the sample output from the pstree command:
init-+-apmd |-atd |-crond |-gpm
|-identd---identd---3*[identd] |-inetd
|-kflushd |-klogd |-kpiod |-kswapd |-kupdate
|-lockd---rpciod |-login---bash---pstree |-lpd
Chapter 13 Process Management 413
|-mdrecoveryd |-5*[mingetty] |-portmap |-pump |-rpc.statd |-sendmail |-syslogd ‘-xfs
Getty
The getty process provides logins from terminals. The init program starts a separate instance of getty for each terminal on which logins are allowed. When the user types his or her name and password, the getty process begins the login program to authenticate the user.
Syslog
The syslog process allows the kernel and many other system programs to produce warnings, errors, and other messages. Syslog is configured to write these events to a file where the administrator can retrieve them at a later date.
Cron
The cron program schedules system tasks and other periodic maintenance programs. The cron program reads a configuration file, and then executes various programs and services at specified times.
Non-critical processes
Processes that are not part of the Linux system are considered non-critical, and are usually programs and applications, such as Web servers and FTP servers. Stopping and starting these processes won’t affect the core functionality of the system.
When killing processes, be sure that you are not terminating a special core process, because you may cause your system to crash.
Process administration
The administrator can use several different commands to manage processes. The following sections detail these commands.
The ps command lists currently running processes. With the ps command, you can check the status of all running processes. You can also customize the way you view the list by using special arguments.
Using the ps command without any arguments only shows the running processes of the current user.
414 Part V Maintaining the Linux System
PID TTY TIME CMD
637 tty1 00:00:00 bash
913 tty1 00:00:00 ps
This example shows the user bash shell running, and the ps command that was just run. The PID shows the process identification number for that process. The TTY column defines which terminal the process was run from. The time lists how long the process has been active.
To see all running processes, use the ps -e command. If you are running as root, the ps command shows all running processes by default. The output looks something like this:
PID |
TTY TIME CMD |
1 |
? 00:00:07 init |
2 ? |
00:00:00 kflushd |
3 ? |
00:00:00 kupdate |
4 ? |
00:00:00 kpiod |
5 ? |
00:00:00 kswapd |
6 ? |
00:00:00 mdrecoveryd |
287 |
? 00:00:00 pump |
301 |
? 00:00:00 portmap |
316 |
? 00:00:00 lockd |
317 |
? 00:00:00 rpciod |
326 |
? 00:00:00 rpc.statd |
340 |
? 00:00:00 apmd |
391 |
? 00:00:00 syslogd |
400 |
? 00:00:00 klogd |
414 |
? 00:00:00 identd |
416 |
? 00:00:00 identd |
418 |
? 00:00:00 identd |
420 |
? 00:00:00 identd |
421 |
? 00:00:00 identd |
432 |
? 00:00:00 atd |
446 |
? 00:00:00 crond |
464 |
? 00:00:00 inetd |
478 |
? 00:00:00 lpd |
522 |
? 00:00:00 sendmail |
537 |
? 00:00:00 gpm |
589 |
? 00:00:00 xfs |
628 |
tty2 00:00:00 mingetty |
629 |
tty3 00:00:00 mingetty |
630 |
tty4 00:00:00 mingetty |
631 |
tty5 00:00:00 mingetty |
632 |
tty6 00:00:00 mingetty |
976 |
tty1 00:00:00 login |
977 |
tty1 00:00:00 bash |
1055 tty1 00:00:00 ps
This example shows all the processes that are currently running on the system. The notable processes include the core services, such as inetd, init, syslogd, and crond. The several mingetty processes refer to the number of terminal sessions
Chapter 13 Process Management 415
available for this instance of Linux. The current user is on tty1, which is why you see the login, bash, and ps processes listed as originating from the terminal tty1.
ps a
This command is similar to ps -e, but this argument displays all processes that originated from that particular TTY or terminal. For example:
PID TTY TIME CMD
976 tty1 00:00:00 login
977 tty1 00:00:00 bash
1055 tty1 00:00:00 ps
ps –u
This command displays all processes run by a particular user. For example, to see all processes run by the user root, use this command: ps -u root.
ps –au
This command displays all processes listed by username.
ps -f
This command displays a more detailed listing of process information, including the owner’s ID, the start time of the process, and the parent process ID (PPID). For example:
UID PID PPID |
C STIME |
TTY TIME CMD |
||
user |
636 628 |
0 |
06:31 |
tty1 00:00:00 -bash |
user |
667 636 |
0 |
06:42 |
tty1 00:00:00 ps -f |
ps –ef
This is the most common command used to list processes. It displays all processes by using the full listing format.
ps | more
The ps command can be piped through other commands to aid in displaying the information. Sometimes, a process list can scroll by too quickly because of all the entries, so you can pipe it through the more command to list it screen by screen.
ps > file.txt
You can use this command to send the output of the ps command to a text file to be stored for later viewing, or to print it to a printer.
Be sure to know and be able to use some of the more popular attributes of the ps command.
