20190923-10Linux process thread Class 000 018

Process is a program or command being executed, each entity is a process that runs, has its own address space, and take up some system resources.

 

 

ps to view the current status of system processes

 

ps: process status process status

 

1. The basic syntax

 

the AUX PS  | grep xxx (functional description: View all processes)

 

-ef PS | grep xxx (Function Description : You can view the child parent relationship between processes) 

 

2. Option Description

 

Table 1-35

 

Options

Features

-a

Select all processes

-u

Display all processes for all users

-x

The process does not display terminal

 

3. Function Description

 

( . 1 ) PS AUX displayed information

 

The USER : The process by which user generated

 

PID : Process ID number

 

CPU% : The process uses CPU percentage of resources, the higher the occupation, the more resource-intensive process;

 

MEM% : The percentage of physical memory occupied by the process, the higher the occupation, the more resource-intensive process;

 

VSZ : This process uses virtual memory size in KB ;

 

RSS : The process uses the size of the actual physical memory, the unit KB ;

 

TTY : The process which is running in the terminal. Which tty1-tty7 behalf of the local terminal console, tty1-tty6 is a local character interface terminal, tty7 is a graphics terminal. pts / 0-255 behalf of the virtual terminal.

 

STAT : process status. Common states are: R : run, S : sleeping, T : Stop state, S : contains sub-process, + : behind the scenes

 

The START : Start time of the process

 

The TIME : This process uses CPU computing time, the attention is not the system time

 

The COMMAND : command name for this process to produce

 

( 2 ) PS  -ef display information described

 

UID : User ID

 

PID : Process ID

 

PPID : parent process ID

 

C : the CPU for calculating the execution priority factor. A higher value process is CPU intensive operations, will reduce the execution priority; Smaller values indicates that the process is I / O intensive operations, execution priority increases

 

STIME : process start time

 

TTY : Complete terminal name

 

The TIME : the CPU time

 

CMD : Command to start the process and parameters used

 

4. Experience Skills

 

If you want to see the process of CPU usage and memory usage , you can use the aux;

 

If you want to see the parent process ID can be used ef;

 

5. Case practical operation

 

[Root @ hadoop101 datas] # ps aux

 

FIG 1-161 shown

 

 

 

 

 

Figure 1-161  view the process of CPU usage and memory usage

 

[root@hadoop101 datas]# ps -ef

 

 

 

FIG 1-162 shown

 

 

 

 

 

Figure 1-162   parent process to see the process ID

 

kill terminate the process

1. The basic syntax

kill [options] process ID (Function Description: kill the process by process ID)

killall process name (Function Description: Kill processes by name , and also supports wildcards, which due to the load becomes too large to be useful when the system is very slow )

2. Option Description

Table 1-36

Options

Features

-9

Indicates force in the process stops immediately

3. Case practical operation

( 1 ) kill the browser process

[root @ hadoop101 Desktop ] # kill -9 5102

( 2 ) by killing the process process name

[root @ hadoop101 Desktop ] # killall firefox

 

 

pstree view the process tree

 

1. The basic syntax

 

pstree [ Options ]

 

2. Option Description

 

Table 1-37

 

Options

Features

-p

Display process PID

-u

It belongs to a user display process

 

 

 

3. Case practical operation

 

( 1 ) show the process pid

 

[root@hadoop101 datas]# pstree -p

 

( 2 ) show the process belongs to the user

 

[root@hadoop101 datas]# pstree -u

 

top view system health

1. Basic Commands

top [ options ]

2. Option Description

Table 1-38

Options

Features

-d number of seconds

Specifies the top command updates every few seconds. The default is 3 seconds top command among interactive mode commands can be executed:

-i

The top does not show any idle or zombie processes.

-p

By specifying monitoring process ID to monitor only the status of a process.

3. Instructions

Table 1-39

operating

Features

P

To CPU usage sort, this is the default

M

To sort of memory usage

N

With PID sorting

q

Exit top

4. Interpretation of field results

The first line of information for the task queue information

Table 1-40

content

Explanation

12:26:46

Current time

up 1 day, 13:32

Runtime system, the machine has been running . 1 days

13 is hours 32 minutes

2 users

Two users currently logged on

load  average:  0.00, 0.00, 0.00

Before the system . 1 min . 5 minutes, 15 average load minutes. Less than generally believed . 1 , the load is small. If greater than 1 , the system load has been exceeded.

The second line process information

Table 1-41

Tasks:  95 total

The total number of processes in the system

1 running

The number of running processes

94 sleeping

Sleep process

0 stopped

Stopping the process

0 zombie

Zombie process. If it is not 0 , you need to manually check the zombie process

The third behavior CPU information

Table 1-42

Cpu(s):  0.1%us

User Mode occupied by the CPU percentage

0.1% its

System Mode occupied by the CPU percentage

0.0% ni

Changed the priority of the user processes CPU percentage

99.7%id

Idle CPU 's CPU percentage

0.1% wa

Waiting for input / occupation process output CPU percentage

0.0%hi

Hardware interrupt request service occupied CPU percentage

0.1% and

软中断请求服务占用的CPU百分比

0.0%st

stSteal  time)虚拟时间百分比。就是当有虚拟机时,虚拟CPU等待实际CPU的时间百分比。

第四行为物理内存信息

1-43

Mem:    625344k total

物理内存的总量,单位KB

571504k used

已经使用的物理内存数量

53840k free

空闲的物理内存数量,我们使用的是虚拟机,总共只分配了628MB内存,所以只有53MB的空闲内存了

65800k buffers

作为缓冲的内存数量

第五行为交换分区(swap)信息

1-44

Swap:   524280k total

交换分区(虚拟内存)的总大小

0k used

已经使用的交互分区的大小

524280k free

空闲交换分区的大小

409280k cached

作为缓存的交互分区的大小

5.案例实操

[root@hadoop101 atguigu]# top -d 1

[root@hadoop101 atguigu]# top -i

[root@hadoop101 atguigu]# top -p 2575

执行上述命令后,可以按PMN对查询出的进程结果进行排序。

 

 

netstat 显示网络统计信息端口占用情况

 

1.基本语法

 

netstat -anp |grep 进程 (功能描述:查看该进程网络信息

 

netstat -nlp | grep 端口号 (功能描述:查看网络端口号占用情况)

 

2.选项说明

 

1-45

 

选项

功能

-n

拒绝显示别名,能显示数字的全部转化成数字

-l

仅列出有在listen(监听)的服务状态

-p

表示显示哪个进程在调用

 

3.案例实操

 

1)通过进程号查看该进程的网络信息

 

[root@hadoop101 hadoop-2.7.2]# netstat -anp | grep 火狐浏览器进程号

 

unix  2      [ ACC ]     STREAM     LISTENING     20670  3115/firefox        /tmp/orbit-root/linc-c2b-0-5734667cbe29

 

unix  3      [ ]         STREAM     CONNECTED     20673  3115/firefox        /tmp/orbit-root/linc-c2b-0-5734667cbe29

 

unix  3      [ ]         STREAM     CONNECTED     20668  3115/firefox        

 

unix  3      [ ]         STREAM     CONNECTED     20666  3115/firefox     

 

 

 

(2)查看某端口号是否被占用

 

[root@hadoop101 桌面]# netstat -nlp | grep 20670 

 

unix  2      [ ACC ]     STREAM     LISTENING     20670  3115/firefox        /tmp/orbit-root/linc-c2b-0-5734667cbe29

 

Guess you like

Origin www.cnblogs.com/YUJIE666/p/11570201.html