Linux中的ps命令是Process Status的缩写。ps命令用来列出系统中当前运行的那些进程。ps命令列出的是当前那些进程的快照,就是执行ps命令的那个时刻的那些进程,如果想要动态的显示进程信息,就可以使用top命令。
--version 显示版本显示
[zhang@localhost document]$ ps -A PID TTY TIME CMD 1 ? 00:00:01 init 2 ? 00:00:00 kthreadd 3 ? 00:00:00 migration/0 4 ? 00:00:00 ksoftirqd/0 5 ? 00:00:00 stopper/0 6 ? 00:00:00 watchdog/0 7 ? 00:00:00 migration/1 8 ? 00:00:00 stopper/1 9 ? 00:00:00 ksoftirqd/1 10 ? 00:00:00 watchdog/1 11 ? 00:00:00 migration/2 12 ? 00:00:00 stopper/2 13 ? 00:00:00 ksoftirqd/2 14 ? 00:00:00 watchdog/2 15 ? 00:00:00 migration/3 16 ? 00:00:00 stopper/3 ......(省略)
[zhang@localhost ~]$ ps -u zhang PID TTY TIME CMD 2657 ? 00:00:00 gnome-keyring-d 2667 ? 00:00:00 gnome-session 2675 ? 00:00:00 dbus-launch 2676 ? 00:00:00 dbus-daemon 2739 ? 00:00:04 gconfd-2 2746 ? 00:00:06 gnome-settings- 2754 ? 00:00:00 gvfsd 2758 ? 00:00:00 seahorse-daemon 2767 ? 00:00:04 gnome-panel 2773 ? 00:00:12 pulseaudio 2781 ? 00:00:00 gconf-helper 2788 ? 00:00:07 nautilus 2790 ? 00:00:00 bonobo-activati 2796 ? 00:00:04 wnck-applet 2798 ? 00:00:00 trashapplet 2804 ? 00:00:00 gvfsd-trash 2806 ? 00:00:00 gvfs-gdu-volume ......(省略)
[zhang@localhost ~]$ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 14:26 ? 00:00:01 /sbin/init root 2 0 0 14:26 ? 00:00:00 [kthreadd] root 3 2 0 14:26 ? 00:00:00 [migration/0] root 4 2 0 14:26 ? 00:00:00 [ksoftirqd/0] root 5 2 0 14:26 ? 00:00:00 [stopper/0] root 6 2 0 14:26 ? 00:00:00 [watchdog/0] root 7 2 0 14:26 ? 00:00:00 [migration/1] root 8 2 0 14:26 ? 00:00:00 [stopper/1] root 9 2 0 14:26 ? 00:00:00 [ksoftirqd/1] root 10 2 0 14:26 ? 00:00:00 [watchdog/1] root 11 2 0 14:26 ? 00:00:00 [migration/2] root 12 2 0 14:26 ? 00:00:00 [stopper/2] root 13 2 0 14:26 ? 00:00:00 [ksoftirqd/2] root 14 2 0 14:26 ? 00:00:00 [watchdog/2] root 15 2 0 14:26 ? 00:00:00 [migration/3] root 16 2 0 14:26 ? 00:00:00 [stopper/3] root 17 2 0 14:26 ? 00:00:00 [ksoftirqd/3] root 18 2 0 14:26 ? 00:00:00 [watchdog/3] root 19 2 0 14:26 ? 00:00:00 [events/0] root 20 2 0 14:26 ? 00:00:00 [events/1] root 21 2 0 14:26 ? 00:00:00 [events/2] root 22 2 0 14:26 ? 00:00:00 [events/3] root 23 2 0 14:26 ? 00:00:00 [cgroup] root 24 2 0 14:26 ? 00:00:00 [khelper] root 25 2 0 14:26 ? 00:00:00 [netns] root 26 2 0 14:26 ? 00:00:00 [async/mgr] ......(省略)
[zhang@localhost ~]$ ps -ef | grep ssh root 1980 1 0 14:26 ? 00:00:00 /usr/sbin/sshd zhang 21211 21146 0 19:35 pts/0 00:00:00 grep ssh
[zhang@localhost ~]$ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 500 21146 21143 0 80 0 - 27050 wait pts/0 00:00:00 bash 0 R 500 21308 21146 1 80 0 - 27032 - pts/0 00:00:00 ps说明:
[zhang@localhost ~]$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 19364 1360 ? Ss 14:26 0:01 /sbin/init root 2 0.0 0.0 0 0 ? S 14:26 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 14:26 0:00 [migration/0] root 4 0.0 0.0 0 0 ? S 14:26 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S 14:26 0:00 [stopper/0] root 6 0.0 0.0 0 0 ? S 14:26 0:00 [watchdog/0] root 7 0.0 0.0 0 0 ? S 14:26 0:00 [migration/1] root 8 0.0 0.0 0 0 ? S 14:26 0:00 [stopper/1] root 9 0.0 0.0 0 0 ? S 14:26 0:00 [ksoftirqd/1] root 10 0.0 0.0 0 0 ? S 14:26 0:00 [watchdog/1] root 11 0.0 0.0 0 0 ? S 14:26 0:00 [migration/2] root 12 0.0 0.0 0 0 ? S 14:26 0:00 [stopper/2] ......(省略)
[zhang@localhost ~]$ ps -axjf Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND 0 2 0 0 ? -1 S 0 0:00 [kthreadd] 2 3 0 0 ? -1 S 0 0:00 \_ [migration/0] 2 4 0 0 ? -1 S 0 0:00 \_ [ksoftirqd/0] 2 5 0 0 ? -1 S 0 0:00 \_ [stopper/0] 2 6 0 0 ? -1 S 0 0:00 \_ [watchdog/0] 2 7 0 0 ? -1 S 0 0:00 \_ [migration/1] 2 8 0 0 ? -1 S 0 0:00 \_ [stopper/1] 2 9 0 0 ? -1 S 0 0:00 \_ [ksoftirqd/1] 2 10 0 0 ? -1 S 0 0:00 \_ [watchdog/1] 2 11 0 0 ? -1 S 0 0:00 \_ [migration/2] 2 12 0 0 ? -1 S 0 0:00 \_ [stopper/2] 2 13 0 0 ? -1 S 0 0:00 \_ [ksoftirqd/2] ......(省略)
[zhang@localhost ~]$ ps -aux | egrep '(cron|syslog)' Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ root 1552 0.0 0.0 249096 1120 ? Sl 14:26 0:00 /sbin/rsyslogd root 2360 0.0 0.0 117328 1392 ? Ss 14:26 0:00 crond
原文地址:http://blog.csdn.net/u014488381/article/details/42216149