linuxps命令参数 linux中ps命令的用法( 二 )


e显示环境变量
f显示程序间的关系
-H 显示树状结构
r显示当前终端的进程
T显示当前终端的所有程序
u指定用户的所有进程
选择参数
-C命令 列出指定命令的状况
--lines行数 每页显示的行数
--width字符数 每页显示的字符数
--help 显示帮助信息
--version 显示版本显示
范例1: 显示所有进程信息
root@localhost :~# ps -A 显示进程信息
PID TTYTIME CMD
1 ?00:00:02 init
2 ?00:00:00 kthreadd
3 ?00:00:00 migration/0
4 ?00:00:00 ksoftirqd/0
5 ?00:00:00 watchdog/0
6 ?00:00:00 events/0
7 ?00:00:00 cpuset
……
范例2: 显示指定用户信息
root@localhost :~# ps -u root //显示root进程用户信息
PID TTYTIME CMD
1 ?00:00:02 init
2 ?00:00:00 kthreadd
3 ?00:00:00 migration/0
4 ?00:00:00 ksoftirqd/0
5 ?00:00:00 watchdog/0
6 ?00:00:00 events/0
7 ?00:00:00 cpuset
8 ?00:00:00 khelper
9 ?00:00:00 netns
10 ?00:00:00 async/mgr
11 ?00:00:00 pm
12 ?00:00:00 sync_supers
13 ?00:00:00 bdi-default
14 ?00:00:00 kintegrityd/0
15 ?00:00:02 kblockd/0
16 ?00:00:00 kacpid
……省略部分结果
30487 ?00:00:06 gnome-terminal
30488 ?00:00:00 gnome-pty-helpe
30489 pts/000:00:00 bash
30670 ?00:00:00 debconf-communi
30749 pts/000:00:15 gedit
30886 ?00:01:10 qtcreator.bin
30894 ?00:00:00 qtcreator.bin
31160 ?00:00:00 dhclient
31211 ?00:00:00 aptd
31302 ?00:00:00 sshd
31374 pts/200:00:00 bash
31397 pts/200:00:00 ps
范例3: 显示指定终端信息
root@localhost :~# ps -u root //显示终端1进程信息
PID TTYTIME CMD
1 ?00:00:02 init
2 ?00:00:00 kthreadd
3 ?00:00:00 migration/0
4 ?00:00:00 ksoftirqd/0
5 ?00:00:00 watchdog/0
6 ?00:00:00 events/0
7 ?00:00:00 cpuset
8 ?00:00:00 khelper
9 ?00:00:00 netns
10 ?00:00:00 async/mgr
11 ?00:00:00 pm
12 ?00:00:00 sync_supers
13 ?00:00:00 bdi-default
14 ?00:00:00 kintegrityd/0
15 ?00:00:02 kblockd/0
16 ?00:00:00 kacpid
……省略部分结果
30487 ?00:00:06 gnome-terminal
30488 ?00:00:00 gnome-pty-helpe
30489 pts/000:00:00 bash
30670 ?00:00:00 debconf-communi
30749 pts/000:00:15 gedit
30886 ?00:01:10 qtcreator.bin
30894 ?00:00:00 qtcreator.bin
31160 ?00:00:00 dhclient
31211 ?00:00:00 aptd
31302 ?00:00:00 sshd
31374 pts/200:00:00 bash
31397 pts/200:00:00 ps
范例4: 显示所有进程信息linuxps命令参数,连同命令行
root@localhost :~# ps -ef //显示所有命令linuxps命令参数,连带命令行
UIDPID PPID C STIME TTYTIME CMD
root10 0 10:22 ?00:00:02 /sbin/init
root20 0 10:22 ?00:00:00 [kthreadd]
root32 0 10:22 ?00:00:00 [migration/0]
root42 0 10:22 ?00:00:00 [ksoftirqd/0]
root52 0 10:22 ?00:00:00 [watchdog/0]
root62 0 10:22 ?/usr/lib/NetworkManager
……省略部分结果
root31302 2095 0 17:42 ?00:00:00 sshd: root@pts/2
root31374 31302 0 17:42 pts/200:00:00 -bash
root314001 0 17:46 ?00:00:00 /usr/bin/python /usr/sbin/aptd
root31407 31374 0 17:48 pts/200:00:00 ps -ef
范例5: ps 与grep 常用组合用法linuxps命令参数,查找特定进程
root@localhost :~# ps -ef |grep sshd //查找字串为sshd的进程
root20951 0 10:31 ?00:00:00 /usr/sbin/sshd
root31302 2095 0 17:42 ?00:00:00 sshd: root@pts/2
root31409 31374 0 17:50 pts/200:00:00 grep --color=auto sshd
root@localhost :~#
范例6: 显示命令的完整命令行
root@localhost :~# ps -efww
UIDPID PPID C STIME TTYTIME CMD
root10 0 10:22 ?00:00:02 /sbin/init
root20 0 10:22 ?00:00:00 [kthreadd]

推荐阅读