The ps command in Linux has two main styles for options: dash-options and no-dash-options, each adhering to different standards:
Dash-Options (e.g., -e, -f)
- POSIX-compliant.
- Options are preceded by a single dash (
-). - Example:
ps -eshows all processes.
No-Dash-Options (e.g., aux)
- BSD-style syntax.
- Options are not preceded by a dash.
- Example:
ps auxshows all processes with additional user and memory details.
Key Difference
- Dash-options often require options to be combined or separated explicitly (
-ef). - No-dash-options are generally more concise but less portable across UNIX variants.
Can I use ps -aux?
You can use ps -aux, but it is not technically correct and may produce unintended results:
-a,-u, andxare BSD-style options. They should be used without a dash, as inps aux.- Using
-auxinvokes POSIX-style syntax, which may causepsto interpret-uas an invalid user name depending on the system.
Correct Usage:
- For BSD-style:
ps aux - For POSIX-style:
ps -eorps -ef
It’s recommended to follow the correct style for clarity and portability.
Can you make an extensive list of ps with dash and no-dash options
Here’s an extensive list of common ps options categorized by dash (-) and no-dash usage styles:
With Dash (-): POSIX Style
| Option | Description |
|---|---|
-a | Show processes from all users (except session leaders). |
-e | Display all processes. Equivalent to -A. |
-f | Full-format listing, including user, PID, PPID, start time, and command. |
-l | Long-format listing. |
-u <user> | Display processes for a specific user. |
-x | Include processes without a controlling terminal. |
-p <pid> | Display specific processes by their process IDs (PIDs). |
-o <fields> | Specify output format by selecting fields (e.g., PID, %CPU, %MEM). |
-H | Show processes in a hierarchical tree view. |
--forest | ASCII-art process tree for visualizing relationships. |
Without Dash: BSD Style
| Option | Description |
|---|---|
a | Show all processes for all users (interactive and non-interactive). |
x | Include processes without a controlling terminal. |
u | Display user-oriented output format. |
ax | Show all processes regardless of terminal association. |
aux | Display all processes with detailed information (user, CPU, memory usage). |
Key Differences
- Dash Style (-): Follows POSIX conventions; options can be combined (e.g.,
-ef) or written separately. - No-Dash Style: Follows BSD conventions; options are written together as a single string (e.g.,
aux).
Example Comparisons
ps -e(POSIX): Display all processes.ps ax(BSD): Equivalent tops -e, but shows all processes using BSD style.
For consistent cross-platform usage, POSIX style (ps -e, ps -f) is preferred, as not all systems support BSD syntax.