2

I am creating an app using the following command to get CPU and memory usage:

ps -A -o %cpu,%mem | awk '{ cpu += $1; mem += $2} END {print cpu , mem}'

I wonder whether all users have permission to run it and get the same results? If there is an admin process, whether the ps command outputs it for a guest user?

2

ps -A shows all processes, regardless of user. From the man page:

-A Display information about other users' processes, including those without controlling terminals.

0

ps has the setuid bit set in which the process runs with the permissions of the owner, root for any user that invokes the command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .