[二星]使用命令来查看当前用户下的所有程序的物理内存消耗

除了美化之外,还可以来尝试挑战一下任务
回复
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

[二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#1

帖子 oneleaf » 2009-12-08 10:24

1 任务内容: 使用命令来查看属于当前用户下的所有程序的物理内存消耗,并从大到小排序

2 任务的难度: 二星

3 任务的目的: 学习linux下的进程统计

4 任务所涉及的软件: ps

5 任务将大致消耗的时间: 1天

6 参考网站: man ps
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#2

帖子 xhy » 2009-12-08 21:52

代码: 全选

ps akvsz -o pid,vsz,cmd
目前负债150多万
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#3

帖子 oneleaf » 2009-12-09 9:14

xhy 写了:

代码: 全选

ps akvsz -o pid,vsz,cmd
不满足要求条件
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#5

帖子 oneleaf » 2009-12-11 12:29

jarodlau 写了:

代码: 全选

ps -U "username"  -o pid,vsz,cmd
不满足: vsz是 virtual memory,不是实际物理内存,并没有按内存大小排序。
头像
自由建客
帖子: 13468
注册时间: 2008-07-30 23:21
系统: Debian stable AMD64

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#6

帖子 自由建客 » 2009-12-15 17:48

怎么统计,不现实吧!共享库怎么算?
fangyd
帖子: 88
注册时间: 2009-04-30 13:03

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#7

帖子 fangyd » 2009-12-15 22:44

新手,看完了 man ps 后得出这个命令,不知对否?

代码: 全选

ps -u username -o pid,user,size,cmd --sort -size
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#9

帖子 oneleaf » 2010-01-05 11:49

rss RSS resident set size, the non-swapped physical memory that a task has used (in kiloBytes). (alias rssize, rsz).
vsz VSZ virtual memory size of the process in KiB (1024-byte units). Device mappings are currently excluded; this is subject to change. (alias vsize).
size SZ approximate amount of swap space that would be required if the process were to dirty all writable pages and then be swapped out. This number is very rough!
sz SZ size in physical pages of the core image of the process. This includes text, data, and stack space. Device mappings are currently excluded; this is subject to change. See vsz and rss.
rss: 才是真实内存占用,因此为:

代码: 全选

ps -u $USER -o pid,rss,cmd --sort -rss
fangyd
帖子: 88
注册时间: 2009-04-30 13:03

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#10

帖子 fangyd » 2010-01-06 21:30

请问,size 表示的是什么 swap 吗?
rss 是包括共享内存?
头像
lxnnix
帖子: 89
注册时间: 2007-08-19 22:24
来自: 南京

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#11

帖子 lxnnix » 2010-08-26 14:06

mark一下。一般用top,然后按M,查看RES列。
LXLE了。
lwm_5927
帖子: 3
注册时间: 2009-12-09 23:34

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#12

帖子 lwm_5927 » 2011-07-12 16:27

代码: 全选

ps -lyu username --sort -rss
头像
cdlxyx
帖子: 20
注册时间: 2010-10-16 2:41

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#13

帖子 cdlxyx » 2011-07-26 9:22

路过。操蛋到路过一下。
己所不欲,勿施于人!
Do as you would be done by !
头像
lxr1234
帖子: 721
注册时间: 2009-04-10 11:15
来自: 三民主义国国民权利省我的选择市中共下台镇

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#14

帖子 lxr1234 » 2011-07-26 21:24

top不是更简单吗?
强烈反对M$的ARM Secure Boot 锁定要求,大家请签名反对
http://www.fsf.org/campaigns/secure-boo ... cted-boot/
头像
ctrl-fairy
帖子: 116
注册时间: 2011-04-28 18:05

Re: [二星]使用命令来查看当前用户下的所有程序的物理内存消耗

#15

帖子 ctrl-fairy » 2012-10-25 20:46

代码: 全选

ps -U $username -o pid,user,rss,cmd --sort=rss
额,原来以为是%mem,额额

代码: 全选

linux和windows对我等菜鸟,都是浮云!
回复