top命令
usage: top [-Hbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]
Show process activity in real time.
-H Show threads
-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)
-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)
-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)
-s Sort by field number (1-X, default 9)
-b Batch mode (no tty)
-d Delay SECONDS between each cycle (default 3)
-m Maximum number of tasks to show
-n Exit after NUMBER iterations
-p Show these PIDs
-u Show these USERs
-q Quiet (no header lines)
Cursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force
update, R to reverse sort, Q to exit.
VIRT:virtual memory usage 虚拟内存
1、进程“需要的”虚拟内存大小,包括进程使用的库、代码、数据等
2、假如进程申请100m的内存,但实际只使用了10m,那么它会增长100m,而不是实际的使用量
RES:resident memory usage 常驻内存
1、进程当前使用的内存大小,但不包括swap out
2、包含其他进程的共享
3、如果申请100m的内存,实际使用10m,它只增长10m,与VIRT相反
4、关于库占用内存的情况,它只统计加载的库文件所占内存大小
SHR:shared memory 共享内存
1、除了自身进程的共享内存,也包括其他进程的共享内存
2、虽然进程只使用了几个共享库的函数,但它包含了整个共享库的大小
3、计算某个进程所占的物理内存大小公式:RES – SHR
4、swap out后,它将会降下来
ps命令
[C:\~]$ adb shell ps --help
usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]
List processes.
Which processes to show (selections may be comma separated lists):
-A All processes
-a Processes with terminals that aren't session leaders
-d All processes that aren't session leaders
-e Same as -A
-g Belonging to GROUPs
-G Belonging to real GROUPs (before sgid)
-p PIDs (--pid)
-P Parent PIDs (--ppid)
-s In session IDs
-t Attached to selected TTYs
-T Show threads
-u Owned by USERs
-U Owned by real USERs (before suid)
Output modifiers:
-k Sort FIELDs in +increasing or -decreasting order (--sort)
-M Measure field widths (expanding as necessary)
-n Show numeric USER and GROUP
-w Wide output (don't truncate fields)
Which FIELDs to show. (Default = -o PID,TTY,TIME,CMD)
-f Full listing (-o USER:12=UID,PID,PPID,C,STIME,TTY,TIME,ARGS=CMD)
-l Long listing (-o F,S,UID,PID,PPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD)
-o Output FIELDs instead of defaults, each with optional :size and =title
-O Add FIELDS to defaults
-Z Include LABEL
Command line -o fields:
ARGS CMDLINE minus initial path CMD Command (thread) name (stat[2])
CMDLINE Command line (argv[]) COMM Command filename (/proc/$PID/exe)
COMMAND Command file (/proc/$PID/exe) NAME Process name (argv[0] of $PID)
Process attribute -o FIELDs:
ADDR Instruction pointer BIT Is this process 32 or 64 bits
CPU Which processor running on ETIME Elapsed time since PID start
F Flags (1=FORKNOEXEC 4=SUPERPRIV) GID Group id
GROUP Group name LABEL Security label
MAJFL Major page faults MINFL Minor page faults
NI Niceness (lower is faster)
PCPU Percentage of CPU time used PCY Android scheduling policy
PGID Process Group ID
PID Process ID PPID Parent Process ID
PRI Priority (higher is faster) PSR Processor last executed on
RGID Real (before sgid) group ID RGROUP Real (before sgid) group name
RSS Resident Set Size (pages in use) RTPRIO Realtime priority
RUID Real (before suid) user ID RUSER Real (before suid) user name
S Process state:
R (running) S (sleeping) D (device I/O) T (stopped) t (traced)
Z (zombie) X (deader) x (dead) K (wakekill) W (waking)
SCHED Scheduling policy (0=other, 1=fifo, 2=rr, 3=batch, 4=iso, 5=idle)
STAT Process state (S) plus:
< high priority N low priority L locked memory
s session leader + foreground l multithreaded
STIME Start time of process in hh:mm (size :19 shows yyyy-mm-dd hh:mm:ss)
SZ Memory Size (4k pages needed to completely swap out process)
TCNT Thread count TID Thread ID
TIME CPU time consumed TTY Controlling terminal
UID User id USER User name
VSZ Virtual memory size (1k units) %VSZ VSZ as % of physical memory
WCHAN What are we waiting in kernel for
UID:用户ID,实际输出的是用户名,如root
PID:当前进程的ID
PPID:当前进程的父进程ID
C:当前进程占用的CPU的百分比
STIME:当前进程启动到现在的时间
TTY:当前进程在哪个终端上运行,若与进程无关,则显示为?,若为pts/0等,则表示由网络连接主机进程。
CMD:命令的名称和参数
进程stat状态
无法中断的休眠状态(通常 IO 的进程);
R 正在运行可中在队列中可过行的;
S 处于休眠状态;
T 停止或被追踪;
W 进入内存交换;
X 死掉的进程;
Z 僵尸进程;
优先级高的进程
N 优先级较低的进程
L 有些页被锁进内存
s 进程的领导者(在它之下有子进程)
l 多进程的(使用 CLONE_THREAD, 类似 NPTL pthreads);
+ 位于后台的进程组;
busybox(toybox)
|console:/ # busybox --help
BusyBox v1.18.3 (2012-12-03 15:06:10 CST) multi-call binary.
Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: busybox --list[-full]
or: function [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.
Currently defined functions:
[, [[, addgroup, adduser, ar, arping, ash, awk, basename, bunzip2,
bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt,
cksum, clear, cmp, cp, cpio, crond, crontab, cut, date, dc, dd,
deallocvt, delgroup, deluser, devmem, df, diff, dirname, dmesg, dnsd,
dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,
ether-wake, expr, false, fdflush, fdformat, fdisk, fgrep, find, fold,
free, freeramdisk, fsck, fuser, getopt, getty, grep, gunzip, gzip,
halt, hdparm, head, hexdump, hostid, hostname, hwclock, id, ifconfig,
ifdown, ifup, inetd, init, insmod, install, ionice, iostat, ip, ipaddr,
ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,
killall5, klogd, last, length, less, linux32, linux64, linuxrc, ln,
loadfont, loadkmap, logger, login, logname, losetup, ls, lsattr, lsmod,
lspci, lsusb, lzcat, lzma, makedevs, md5sum, mdev, mesg, microcom,
mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.vfat, mknod, mkswap,
mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mt, mv,
nameif, netstat, nice, nohup, nslookup, od, openvt, passwd, patch,
pidof, ping, pipe_progress, pivot_root, poweroff, printenv, printf, ps,
pwd, rdate, readahead, readlink, readmbr, readprofile, realpath,
reboot, renice, reset, resize, rm, rmdir, rmmod, route, run-parts,
runlevel, sed, seq, setarch, setconsole, setkeycodes, setlogcons,
setsid, sh, sha1sum, sha256sum, sha512sum, sleep, sort,
start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,
switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, test, tftp,
time, top, touch, tr, traceroute, true, tty, udhcpc, umount, uname,
uniq, unix2dos, unlzma, unxz, unzip, uptime, usleep, uudecode,
uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which, who,
whoami, xargs, xz, xzcat, yes, zcat
console:/ #