ps command: how does the '-q' option work?
According with the
ps command, for the
man is indicated:
-q pidlist Select by PID (quick mode). This selects the processes whose process ID numbers appear in pidlist. With this option ps reads the necessary info only for the pids listed in the pidlist and doesn't apply additional filtering rules. The order of pids is unsorted and preserved. No additional selection options, sorting and forest type listings are allowed in this mode. Identical to q and --quick-pid.
ps --help a
-q, q, --quick-pid <PID> process id (quick mode)
But is not clear for me about the following parts:
- What does (quick mode) mean? – quick about what?
- What does With this option ps reads the necessary info only for the pids listed in the pidlist and doesn’t apply additional filtering rules mean?
- What does The order of pids is unsorted and preserved mean? – why is unsorted if theoretically we are defining the explicit set of pids? I mean
ps -q <pid1>,<pid2>,...,<pidN>
- Therefore with these three first questions: When is mandatory use this
psretrieves information about all the processes in the system, before applying any filters.
-qis quick because it disables this behaviour: with
psonly retrieves information for the listed pids.
pssorts its output according to its sort parameters. By default, it sorts by pid, so
ps 102 101 100will show pids 100, 101, and 102 (if they exist) in that order.
-qdoesn’t sort, so
ps -q 102,101,100will show pids 102, 101, and 100 in that order.
It’s an option, it’s never mandatory. It’s useful if you want information on specific pids and nothing else; in such cases it can save a significant amount of time.