[ Pobierz całość w formacie PDF ]
.Some processescan spawn other processes, which are called child processes.If you stop a child pro-cess, the parent process will continue.However, if you stop the parent process,each child process is also stopped.A process uses several system resources whenrunning, 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 allocatestemporary storage for processing.&' Physical Devices: Allows processes to access physical devices, such asmonitors, hard drives, and printers.The system tracks each process for its usage of these resources, and allocatesthese resources as needed to the process that needs them the most.Some pro-cesses are given priority over others, while the other processes must  wait theirturn 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. 194881-6 ch13.F 11/12/01 8:31 AM Page 412Part V &' Maintaining the Linux System412&' Waiting: The process is waiting for a particular resource to become available.&' Zombie: The process has stopped but is still consuming resources; also oftenreferred 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, whichtracks each process.This number allows the administrator to more easily differenti-ate between processes while managing the system.The PID can also be used inconjunction with several commands to change the state of a process.Core services versus non-critical services5.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 criticalprograms that the Linux kernel needs in order to function properly.These pro-cesses are run at boot time, and are usually referred to as  daemons.For the exam, be careful to differentiate the core services from regular applicationand user processes.InitThe most important service in a Linux system is provided by init.Initstartswhen the system boots, and continues the boot process by performing variousstartup jobs, such as checking and mounting file systems, and starting services anddaemons.When the system is shut down, the initprocess stops all other pro-cesses, unmounts the file systems, and halts the system.All processes are spawned from init.Many Linux startup services and daemonsare spawned from the initprocess.The command pstreegives you a list of all theprocesses in a  tree format, so you can easily discern the parent and child pro-cesses.This is the sample output from the pstreecommand:init-+-apmd|-atd|-crond|-gpm|-identd---identd---3*[identd]|-inetd|-kflushd|-klogd|-kpiod|-kswapd|-kupdate|-lockd---rpciod|-login---bash---pstree|-lpd 194881-6 ch13.F 11/12/01 8:31 AM Page 413Chapter 13 &' Process Management413|-mdrecoveryd|-5*[mingetty]|-portmap|-pump|-rpc.statd|-sendmail|-syslogd -xfsGettyThe gettyprocess provides logins from terminals.The initprogram starts aseparate instance of gettyfor each terminal on which logins are allowed.Whenthe user types his or her name and password, the gettyprocess begins the loginprogram to authenticate the user.SyslogThe syslogprocess allows the kernel and many other system programs to producewarnings, errors, and other messages.Syslogis configured to write these events toa file where the administrator can retrieve them at a later date.CronThe cronprogram schedules system tasks and other periodic maintenanceprograms.The cronprogram reads a configuration file, and then executes variousprograms and services at specified times.Non-critical processesProcesses that are not part of the Linux system are considered non-critical, and areusually programs and applications, such as Web servers and FTP servers.Stoppingand 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 administrationThe administrator can use several different commands to manage processes.Thefollowing sections detail these commands.The pscommand lists currently running processes.With the pscommand, you cancheck the status of all running processes.You can also customize the way you viewthe list by using special arguments.Using the pscommand without any arguments only shows the running processes ofthe current user. 194881-6 ch13.F 11/12/01 8:31 AM Page 414Part V &' Maintaining the Linux System414PID TTY TIME CMD637 tty1 00:00:00 bash913 tty1 00:00:00 psThis example shows the user bash shell running, and the pscommand that was justrun.The PID shows the process identification number for that process.The TTYcolumn defines which terminal the process was run from.The time lists how longthe process has been active.To see all running processes, use the ps -ecommand.If you are running as root,the pscommand shows all running processes by default.The output looks some-thing like this:PID TTY TIME CMD1 ? 00:00:07 init2 ? 00:00:00 kflushd3 ? 00:00:00 kupdate4 ? 00:00:00 kpiod5 ? 00:00:00 kswapd6 ? 00:00:00 mdrecoveryd287 ? 00:00:00 pump301 ? 00:00:00 portmap316 ? 00:00:00 lockd317 ? 00:00:00 rpciod326 ? 00:00:00 rpc.statd340 ? 00:00:00 apmd391 ? 00:00:00 syslogd400 ? 00:00:00 klogd414 ? 00:00:00 identd416 ? 00:00:00 identd418 ? 00:00:00 identd420 ? 00:00:00 identd421 ? 00:00:00 identd432 ? 00:00:00 atd446 ? 00:00:00 crond464 ? 00:00:00 inetd478 ? 00:00:00 lpd522 ? 00:00:00 sendmail537 ? 00:00:00 gpm589 ? 00:00:00 xfs628 tty2 00:00:00 mingetty629 tty3 00:00:00 mingetty630 tty4 00:00:00 mingetty631 tty5 00:00:00 mingetty632 tty6 00:00:00 mingetty976 tty1 00:00:00 login977 tty1 00:00:00 bash1055 tty1 00:00:00 psThis example shows all the processes that are currently running on the system.Thenotable processes include the core services, such as inetd, init, syslogd, andcrond.The several mingettyprocesses refer to the number of terminal sessions 194881-6 ch13.F 11/12/01 8:31 AM Page 415Chapter 13 &' Process Management415available for this instance of Linux.The current user is on tty1, which is why yousee the login, bash, and psprocesses listed as originating from the terminal tty1.ps aThis command is similar to ps -e, but this argument displays all processes thatoriginated from that particular TTY or terminal.For example:PID TTY TIME CMD976 tty1 00:00:00 login977 tty1 00:00:00 bash1055 tty1 00:00:00 psps  uThis command displays all processes run by a particular user.For example, to seeall processes run by the user root, use this command: ps -u root.ps  auThis command displays all processes listed by username.ps -fThis command displays a more detailed listing of process information, includingthe owner s ID, the start time of the process, and the parent process ID (PPID).Forexample:UID PID PPID C STIME TTY TIME CMDuser 636 628 0 06:31 tty1 00:00:00 -bashuser 667 636 0 06:42 tty1 00:00:00 ps -fps  efThis is the most common command used to list processes.It displays all processesby using the full listing format [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • swpc.opx.pl
  •