0

While I find the -f option to ps really useful, I miss the numerical UIDs in the output.

Using ps -Ao uid it's possible to display the numerical UIDs:

nlykkei@debian:/proc/1839/net$ ps -Af | head -n5
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 02:00 ?        00:00:09 /lib/systemd/systemd --system --deserialize 17
root         2     0  0 02:00 ?        00:00:00 [kthreadd]
root         3     2  0 02:00 ?        00:00:00 [rcu_gp]
root         4     2  0 02:00 ?        00:00:00 [rcu_par_gp]


nlykkei@debian:/proc/1839/net$ ps -Ao uid,user,pid,command | head -n5
  UID USER       PID COMMAND
    0 root         1 /lib/systemd/systemd --system --deserialize 17
    0 root         2 [kthreadd]
    0 root         3 [rcu_gp]
    0 root         4 [rcu_par_gp]

Is it possible to add the numerical UIDs to the output of ps -Af? I cannot use ps -Af -o uid, and I don't want to type all of the columns that the -f option provides manually?

Shuzheng
  • 4,411

1 Answers1

2

Since you’re using Debian, your ps supports combined so-called “BSD-style” and “Unix-style” options, you can use the n option which uses numbers for WCHAN and USER:

ps n -Af
Stephen Kitt
  • 434,908
  • thanks. Can you say what exactly "WCHAN" refers too? – Shuzheng Jan 26 '20 at 13:42
  • For sleeping processes, it’s the kernel function inside which they’re sleeping. See the manpage for details. – Stephen Kitt Jan 26 '20 at 13:59
  • 1
    That is not really a BSD option, of course. It's what one ps command's manual erroneously describes as BSD options. Actually, it's that pscommand's own idiosyncratic option. https://unix.stackexchange.com/a/511530/5132 – JdeBP Jan 26 '20 at 16:20
  • @StephenKitt - why does the n take precedence over -f, when displaying the output? I'm just wondering why it makes the UID column display numerically? Furthermore, isn't it wrong for the -f option to name the column UID, when it displays usernames? There is a distinction between -o uid and -o user... – Shuzheng Jan 27 '20 at 18:27
  • @StephenKitt - Also, I don't see any WCHAN in the output on Debian 9? – Shuzheng Jan 27 '20 at 18:31