ps 究竟是 aux 还是 ef
生活随笔
收集整理的這篇文章主要介紹了
ps 究竟是 aux 还是 ef
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 1 Overview
- 2 aux or ef
- 3 stand syntax
- 4 BSD syntax
- 5 Summary
1 Overview
相信肯定會有同學有遇到過一個面試題,問:如何查看系統當前所有的進程?
這個答案相信大部分人都知道,當然就是 ps 了。但是,如果你回到 ps aux,如果考官問你是否知道 ps -ef 呢?又或者反過來呢?
本文就這個問題簡單解答一下。
2 aux or ef
這種問題要解決,也是非常容易的,當然就是查手冊了!man ps。
...省略... To see every process on the system using standard syntax:ps -eps -efps -eFps -elyTo see every process on the system using BSD syntax:ps axps axu ...省略...很明顯,不管是 ps aux 還是 ps -ef,都能打印系統所有的進程,那么局別在哪里呢?其實就是在于打印的格式。
3 stand syntax
舉個例子。
# ps -ef | head -n 10 UID PID PPID C STIME TTY TIME CMD root 1 0 0 2018 ? 00:02:04 /sbin/init root 2 0 0 2018 ? 00:00:05 [kthreadd] root 3 2 0 2018 ? 00:03:03 [ksoftirqd/0] root 5 2 0 2018 ? 00:00:00 [kworker/0:0H] root 8 2 0 2018 ? 00:02:15 [migration/0] root 9 2 0 2018 ? 00:00:00 [rcu_bh]4 BSD syntax
舉個例子。
ps aux | head -n 10 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 22388 1620 ? Ss 2018 2:04 /sbin/init root 2 0.0 0.0 0 0 ? S 2018 0:05 [kthreadd] root 3 0.0 0.0 0 0 ? S 2018 3:03 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< 2018 0:00 [kworker/0:0H] root 8 0.0 0.0 0 0 ? S 2018 2:15 [migration/0] root 9 0.0 0.0 0 0 ? S 2018 0:00 [rcu_bh] root 10 0.0 0.0 0 0 ? S 2018 0:00 [rcuob/0] root 11 0.0 0.0 0 0 ? S 2018 0:00 [rcuob/1] root 12 0.0 0.0 0 0 ? S 2018 0:00 [rcuob/2]A5 Summary
https://askubuntu.com/questions/129962/ps-ef-vs-ps-aux
從以上那個回答來看 ps -e 和 ps ax 是幾乎相同的,但是我們從手冊可以看到,-f 和 x 選項會有一些局別,如下。
...省略...x Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes owned by you (same EUID as ps), or to list all processes when used together with the a option. ...省略...-f does full-format listing. This option can be combined with many other UNIX-style options to add additional columns. It also causes the command arguments to be printed. When used with -L, the NLWP (number of threads) and LWP (thread ID) columns will be added. See the c option, the format keyword args, and the format keyword comm.根據手冊來看,x 就是打印 BSD 風格,-f 同樣也是打印格式的問題。
總體來說,如果只是需要 grep 或者拉進程號之列的操作,以上區別是沒有實際意義的,用戶可以忽略。
總結
以上是生活随笔為你收集整理的ps 究竟是 aux 还是 ef的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 利用Python爬取微信好友头像
- 下一篇: (转载)BOX2D V2.3.0 用户手