Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make ps command to show user, PID, terminal, CMD

Tags:

shell

unix

I need to use command that shows all processes related to terminal. Ps -a looks good except that there is no username printed. This command prints:

  PID TTY         TIME   CMD
  26969 pts/34      0:00 man
  27636 pts/2       0:00 awk
  25215 pts/35      0:00 bash

I would like it to be similar to this:

  PID   TTY         TIME CMD  USER  
  26969 pts/34      0:00 man  name
  27636 pts/2       0:00 awk  name
  25215 pts/35      0:00 bash name

Columns order does not matter

like image 778
wooden Avatar asked Oct 22 '25 13:10

wooden


1 Answers

Use:

ps a -o pid,tty,etime,cmd,user

From ps manual:

SIMPLE PROCESS SELECTION

   a    ... An alternate description is that this option causes ps to list all processes with a terminal (tty), or to list all processes

when used together with the x option.

STANDARD FORMAT SPECIFIERS

   Here are the different keywords that may be used to control the output format (e.g. with option -o) or to sort the selected processes

with the GNU-style --sort option.

   For example:  ps -eo pid,user,args --sort user
like image 199
Juan Diego Godoy Robles Avatar answered Oct 25 '25 05:10

Juan Diego Godoy Robles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!