About the ps command - to add one/many extra column/header with the default headers according with the option(s) used with the ps command - it through O the option.
Intro
If ps x is executed the output is as follows:
PID TTY STAT TIME COMMAND
1677 ? Ss 0:00 /lib/systemd/systemd --user
1679 ? S 0:00 (sd-pam)
1704 tty1 S+ 0:00 -bash
1961 tty4 S 0:00 -bash
1973 tty4 S+ 0:00 man ps
1983 tty4 S+ 0:00 pager
2227 ? S 0:00 sshd: manueljordan@pts/0
2228 pts/0 Ss 0:00 -bash
2307 ? S 0:01 sshd: manueljordan@pts/1
2308 pts/1 Ss 0:00 -bash
2407 ? S 0:00 sshd: manueljordan@pts/2
2408 pts/2 Ss 0:00 -bash
2437 pts/2 S+ 0:00 less
2846 pts/1 S+ 0:00 man ps
2856 pts/1 S+ 0:00 pager
2968 pts/0 R+ 0:00 ps x
Appears and we know the default set of column/headers.
How a simple confirmation - if ps xO %cpu is executed the output is as follows:
PID %CPU S TTY TIME COMMAND
1677 0.0 S ? 00:00:00 systemd
1679 0.0 S ? 00:00:00 (sd-pam)
1704 0.0 S tty1 00:00:00 bash
1961 0.0 S tty4 00:00:00 bash
1973 0.0 S tty4 00:00:00 man
1983 0.0 S tty4 00:00:00 pager
2227 0.0 S ? 00:00:00 sshd
2228 0.0 S pts/0 00:00:00 bash
2307 0.0 S ? 00:00:01 sshd
2308 0.0 S pts/1 00:00:00 bash
2407 0.0 S ? 00:00:00 sshd
2408 0.0 S pts/2 00:00:00 bash
2437 0.0 S pts/2 00:00:00 less
2846 0.0 S pts/1 00:00:00 man
2856 0.0 S pts/1 00:00:00 pager
2969 0.0 R pts/0 00:00:00 ps
Until here all is ok. No reason to create this post
Therefore theoretically can be added any HEADER based on with its respective CODE - it according with the STANDARD FORMAT SPECIFIERS section, it available through man ps.
Now thanks with the experience of this question:
Appears the PSR column/header.
Situation
If ps xO psr is executed the output is as follows:
PID TTY STAT TIME COMMAND
1677 ? Ss 0:00 /lib/systemd/systemd --user
1679 ? S 0:00 (sd-pam)
1704 tty1 S+ 0:00 -bash
1961 tty4 S 0:00 -bash
1973 tty4 S+ 0:00 man ps
1983 tty4 S+ 0:00 pager
2227 ? S 0:00 sshd: manueljordan@pts/0
2228 pts/0 Ss 0:00 -bash
2307 ? S 0:01 sshd: manueljordan@pts/1
2308 pts/1 Ss 0:00 -bash
2407 ? S 0:00 sshd: manueljordan@pts/2
2408 pts/2 Ss 0:00 -bash
2437 pts/2 S+ 0:00 less
2846 pts/1 S+ 0:00 man ps
2856 pts/1 S+ 0:00 pager
2975 pts/0 R+ 0:00 ps xO psr
If you realize the PSR does not appear, why?
But if ps xO %cpu,psr is executed the output is:
PID %CPU PSR S TTY TIME COMMAND
1677 0.0 1 S ? 00:00:00 systemd
1679 0.0 2 S ? 00:00:00 (sd-pam)
1704 0.0 1 S tty1 00:00:00 bash
1961 0.0 0 S tty4 00:00:00 bash
1973 0.0 1 S tty4 00:00:00 man
1983 0.0 2 S tty4 00:00:00 pager
2227 0.0 3 S ? 00:00:00 sshd
2228 0.0 3 S pts/0 00:00:00 bash
2307 0.0 3 S ? 00:00:01 sshd
2308 0.0 3 S pts/1 00:00:00 bash
2407 0.0 0 S ? 00:00:00 sshd
2408 0.0 0 S pts/2 00:00:00 bash
2437 0.0 0 S pts/2 00:00:00 less
2846 0.0 0 S pts/1 00:00:00 man
2856 0.0 0 S pts/1 00:00:00 pager
2981 0.0 0 R pts/0 00:00:00 ps
or if ps xO uname,psr is executed the output is:
PID USER PSR S TTY TIME COMMAND
1677 manuelj+ 1 S ? 00:00:00 systemd
1679 manuelj+ 2 S ? 00:00:00 (sd-pam)
1704 manuelj+ 1 S tty1 00:00:00 bash
1961 manuelj+ 0 S tty4 00:00:00 bash
1973 manuelj+ 1 S tty4 00:00:00 man
1983 manuelj+ 2 S tty4 00:00:00 pager
2227 manuelj+ 3 S ? 00:00:00 sshd
2228 manuelj+ 3 S pts/0 00:00:00 bash
2307 manuelj+ 3 S ? 00:00:01 sshd
2308 manuelj+ 3 S pts/1 00:00:00 bash
2407 manuelj+ 0 S ? 00:00:00 sshd
2408 manuelj+ 0 S pts/2 00:00:00 bash
2437 manuelj+ 0 S pts/2 00:00:00 less
2846 manuelj+ 0 S pts/1 00:00:00 man
2856 manuelj+ 0 S pts/1 00:00:00 pager
2982 manuelj+ 0 R pts/0 00:00:00 ps
How you can see when is declared at least another extra header to be added together with the PSR header, just then/only PSR appears in the output.
Why the PSR header does not appear when is declared how the unique extra header to be added through the O option? Is it an expected behavior for some reason?
procps-ng 3.3.16implementation says ofOthat it is "(overloaded)" and that "Heuristics are used to determine the behavior of this option." - my guess is that the heuristic in this case identifiesOpsras a sort option with a set ofOBSOLETE SORT KEYS, rather than as a "user-defined output format with some common fields predefined".