linux常用命令

本文详细介绍了Linux系统中ps命令用于查看进程及其资源占用情况,包括查看所有进程、指定参数筛选和CPU占用最高线程。同时,top命令的界面和功能也被深入解读,包括实时负载、内存使用、进程状态和资源分配。
摘要由CSDN通过智能技术生成

进程管理

ps命令

查看所有进程:ps -efl

查看指定参数:ps -eo pid,ppid,pgid,sid

查看CPU占用最高的进程:

ps -eo pid,pcpu k pcpu | tail -1
ps -eo pid,pcpu --sort pcpu | tail -1
ps -eo pid,pcpu | sort -nk 2 | tail -2

k和--sort一样,tail -1和tail -n 1一样。

sort:-n按字符串排序,-k 2表示根据输入的第2项排序(即pcpu)

查看CPU占用最高的线程:

ps H -eo pid,tid,%cpu k pcpu | tail -1

top命令

第一行        

 当前时间,系统运行了2天13小时25分,用户数,过去1,5,15分钟的系统负载

第二行

任务或线程统计,按H切换显示线程或者任务

第三行

第四行和第五行

按大写E切换内存显示单位(MB,KB等)

第四行是物理内存,第五行是虚拟内存

第六行

PID进程ID
USER用户名
PR优先级
NInice值,负值优先级高
VIRT

Virtual Memory Size (KiB)

The total amount of virtual memory used by the task.  It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.

RES

​Resident Memory Size (KiB)

A subset of the virtual address space (VIRT) representing the non-swapped physical memory a task is currently using.  It is also the sum of the RSan, RSfd and RSsh fields.

SHR

Shared Memory Size (KiB)

A subset of resident memory (RES) that may be used by other processes. It will include shared anonymous pages and shared file-backed pages.  It also includes private pages mapped to files representing program images and shared libraries.

S

进程状态

D = uninterruptible sleep
I = idle
R = running
S = sleeping
T = stopped by job control signal
t = stopped by debugger during trace
Z = zombie

Tasks shown as running should be more properly thought of as ready to run  --  their task_struct is simply represented on the Linux run-queue.  Even without a true SMP machine, you may see numerous tasks in this state depending on top's delay interval and nice value.

%CPUThe task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported.  You toggle Threads mode with the `H' interactive command.
Also for multi-processor environments, if Irix mode is Off, top will operate in Solaris mode where a task's cpu usage will be divided by the total number of CPUs.  You toggle Irix/Solaris modes with the `I' interactive command.
Note: When running in forest view mode (`V') with children collapsed (`v'), this field will also include the CPU time of those unseen children.  See topic 4c. TASK AREA Commands, CONTENT for more information regarding the `V' and `v' toggles.
%MEM

Memory Usage (RES)

A task's currently resident share of available physical memory.

TIME+

CPU Time, hundredths

The same as TIME, but reflecting more granularity through hundredths of a second.

COMMAND

Command Name or Command Line

Display the command line used to start a task or the name of the associated program.  You toggle between command line and name with `c', which is both a command-line option and an interactive command.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值