Monitoring and Managing Linux Processes
| Overview | |
| Goal | To evaluate and control processes running on a Lunix system |
| Objectives |
|
| Sections |
|
| Lab | Monitoring and Managing Linux Process |
Section 1: Process
What is process?
A process is a running instance of a launched, executable program. A process consists of:
- an address space of allocated memory,
- secuirty properties including ownership credentials and privileges
- one or more execution threads of program code, and
- the process state.
An existing(Parent) process duplicates its own address space(fork) to create a new(child) process structure. Every new process is assigned a unique process ID(PID) for tracking and security. The PID and the Parents? Process ID(PPID) are elements of the new process enviroment. All processes are descendants of the first system process, systemd.
| Name | Flag | Kernel-defined state name and description |
| Running | R | TASK_RUNNING: The process is either executing on a CPU or waiting to run. Process can be executing user routines or kernel routines(system calls), or be queued and ready when in the Running(or Runnable) state. |
| Sleeping | S | TASK_INTERRUPTIBLE: |
| D | TASK_UNINTERRUPTIBLE | |
| K | TASK_KILLABLE | |
| Stopped | T | TASK_STOPPED |
| T | TASK_TRACKED | |
| Zombie | Z | EXIT_ZOMBIE |
| X | EXIT_DEAD |
Listing processes
the ps command is used for listing current processes. The command can provide detailed process infomation, include:
- the UID which determines process privileges
- PID
- the CPU and real time already expended
- how much memory the process has allocated in various locations
- the location of process STDOUT, known as the controlling terminal, and
- the current process state
Note: The linux version of ps supports three option formats, including:
- UNIX(POSIX) options
- BSD options
- GNU long options
for example, ps -aux not the same as ps aux
原文:http://www.cnblogs.com/elewei/p/4767696.html