⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rhl40.htm

📁 linux的初学电子书
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML>

<HEAD>

<TITLE>Red Hat Linux Unleashed rhl40.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/htindex.htm">

<LINK REL="Next" HREF="rhl41.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl41.htm">

<LINK REL="Previous" HREF="rhl39.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl39.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A>

<H2>Red Hat Linux Unleashed rhl40.htm</H2>

<P ALIGN=LEFT>

<A HREF="rhl39.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl39.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="rhl41.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl41.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E340" >Processes</A>

<UL>

<LI>

<A HREF="#E69E453" >Types of Processes</A></UL>

<LI>

<A HREF="#E68E341" >Using the ps Command</A>

<UL>

<LI>

<A HREF="#E69E454" >ps Command Output</A>

<LI>

<A HREF="#E69E455" >Login Shells</A>

<LI>

<A HREF="#E69E456" >For the Superuser</A>

<LI>

<A HREF="#E69E457" >Useful ps options</A>

<UL>

<LI>

<A HREF="#E70E11" >For System Administrators</A></UL></UL>

<LI>

<A HREF="#E68E342" >Using kill</A>

<UL>

<LI>

<A HREF="#E69E458" >killing Child Processes</A>

<LI>

<A HREF="#E69E459" >killing Rights</A></UL>

<LI>

<A HREF="#E68E343" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E40"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>40</B></FONT></CENTER></H1>

<BR>

<A NAME="E67E40"></A>

<H2 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>Processes</B></FONT></CENTER></H2>

<BR>

<P>Everything that runs on a Linux system is a process&#151;every user task, every system daemon&#151;everything is a process. Knowing how to manage the processes running on your Linux system is an important (indeed even critical) aspect of system 
administration. This chapter looks processes in some detail. In this chapter you will see:

<BR>

<UL>

<LI>How to find out what processes are running

<BR>

<BR>

<LI>Determine when a process is hogging the system

<BR>

<BR>

<LI>How to find out which processes are locked up

<BR>

<BR>

<LI>How to terminate a process

<BR>

<BR>

<LI>How to properly manage processes

<BR>

<BR>

</UL>

<P>In the course of discussing processes, we don't bother with the mechanics behind how processes are allocated, or how the Linux kernel manages to time-slice all the processes to run a multitasking operating system. Instead, we'll look at the nitty-gritty 
aspects of process control that you need in order to keep your system running smoothly.

<BR>

<P>You may come across the terms process and job used when dealing with multitasking operating systems. For most purposes, both terms are correct. However, a job is usually a process started by a shell (and may involve many processes), while a process is a 
single entity that is executing. To be correct, we'll use the term process throughout.

<BR>

<BR>

<A NAME="E68E340"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Processes</B></FONT></CENTER></H3>

<BR>

<P>A formal definition of a process is that it is a single program running in its own virtual address space. This means that everything running under Linux is a process. This is compared to a job, which may involve several commands executing in series. 
Alternatively, a single command line issued at the shell prompt may involve more than one process, especially when pipes or redirection are involved. For example, the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">nroff -man ps.1 | grep kill | more</FONT></PRE>

<P>will start three processes, one for each command.

<BR>

<BR>

<A NAME="E69E453"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Types of Processes</B></FONT></CENTER></H4>

<BR>

<P>There are several types of processes involved with the Linux operating system. Each has its own special features and attributes. The processes involved with Linux are:

<BR>

<UL>

<LI>Interactive processes: A process initiated from (and controlled by) a shell. Interactive processes may be in foreground or background.

<BR>

<BR>

<LI>Batch processes: Processes that are not associated with a terminal but are submitted to a queue to be executed sequentially.

<BR>

<BR>

<LI>Daemon processes: Processes usually initiated when Linux boots and that run in the background until required.

<BR>

<BR>

</UL>

<BR>

<A NAME="E68E341"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Using the </B><B>ps</B><B> Command</B></FONT></CENTER></H3>

<BR>

<P>The easiest method of finding out what processes are running on your system is to use the ps (process status) command. The ps command has a number of options and arguments, although most system administrators use only a couple of common command-line 
formats. We can start by looking at the basic usage of the ps command, and then examine some of the useful options.

<BR>

<P>The ps command is available to all system users, as well as root, although the output changes a little depending on whether you are logged in as root when you issue the command.

<BR>

<P>When you are logged in as a normal system user (in other words, any login but root) and issue the ps command on the command line by itself, it displays information about every process you are running. For example, you might see the following output when 
you issue the command:

<BR>

<PRE>

<FONT COLOR="#000080">$ ps

PID TTY STAT TIME COMMAND

41 v01 S 0:00 -bash

134 v01 R 0:00 ps</FONT></PRE>

<BR>

<A NAME="E69E454"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>ps</B><B> Command Output</B></FONT></CENTER></H4>

<BR>

<P>The output of the ps command is always organized in columns. Every process on the system has to have a unique identifier so Linux can tell which processes it is working with. Linux handles processes by assigning a unique number to each process, called 
the &quot;Process ID&quot; number (or PID). PIDs start at zero when the system is booted and increment by one for each process run, up to some system-determined number (such as 65,564) at which point it starts numbering from zero again, ignoring those that 
are still active. Usually, the lowest-number processes are the system kernel and daemons, which start when Linux boots and remain active as long as Linux is running. When you are working with processes (such as terminating them), you must use the PID.

<BR>

<P>The TTY column in the ps command output shows you which terminal the process was started from. If you are logged in as a user, this will usually be your terminal or console window. If you are running on multiple console windows, you will see all the 
processes you started in every window displayed.

<BR>

<P>The STAT column in the ps command output shows you the current status of the process. The two most common entries in the status column are S for sleeping and R for running. A running process is one that is currently executing on the CPU. A sleeping 
process is one which isn't currently active. Processes may switch between sleeping and running many times every second.

<BR>

<P>The TIME column shows the total amount of system (CPU) time used by the process so far. These numbers tend to be very small for most processes because they require only a short time to complete. The numbers under the TIME column are a total of the CPU 
time, not the amount of time the process has been alive.

<BR>

<P>Finally, the COMMAND column contains the name of the command line you are running. This is usually the command line you used, although some commands start up other processes. These are called &quot;child&quot; processes, and they show up in the ps 
output as if you had entered them as commands.

<BR>

<BR>

<A NAME="E69E455"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Login Shells</B></FONT></CENTER></H4>

<BR>

<P>As a general convention, a login shell has a hyphen placed before its name (such as -bash in the previous output) to help you distinguish the startup shell from any shells you may have started afterwards. Any other shells that appear in the output do 
not have the hyphen in front of the name, as the following example shows:

<BR>

<PRE>

<FONT COLOR="#000080">$ ps

PID TTY STAT TIME COMMAND

46 v01 S 0:01 -bash

75 v01 S 0:00 pdksh

96 v01 R 0:00 bash

123 v01 R 0:00 ps</FONT></PRE>

<P>This output shows that the user's startup shell is bash (PID 46), and that he or she started up the Korn shell (pdksh, PID 75) and another Bourne shell (bash, PID 96) afterward.

<BR>

<P>Notice in the preceding outputs that the command that actually showed you the process status, ps, appears on the output because it was running when you issued the command. The ps command always appears on the output.

<BR>

<BR>

<A NAME="E69E456"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>For the Superuser</B></FONT></CENTER></H4>

<BR>

<P>When normal users issue the ps command, they see only their own processes. If you issue the ps command when you are logged in as the superuser (usually root, although you can change the name), you will see all the processes on the system, because the 
root login owns everything running. This can produce very long outputs, especially on a system with several users, so you probably want to pipe the output from the ps command to a page filter (such as more or less), or save the output in a file for further 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -