linux ps command to list number of running processes in super user root

Posted on

Problem :

I am looking for. a command that I can list the number of running processes by superuser root and pipe it to wc -l

i already did ps -ef | grep ^$USER wc -l however that only shows for the current user

Solution :

To display all root processes use:

sudo ps -U root -u root -o comm= | wc -l

Where:

  • -U : select real user ID

  • -u : select effective user ID

  • -o comm= : select no columns, so the header line will not be output.

Leave a Reply

Your email address will not be published. Required fields are marked *