As the root user, which command lists all processes running as root and displays their names?

Prepare for the Red Hat Certified Systems Admin Exam EX200. Enhance your skills with interactive quizzes, flashcards, and detailed explanations. Ace your certification exam today!

Multiple Choice

As the root user, which command lists all processes running as root and displays their names?

Explanation:
The key is filtering processes by the user identity that determines who is currently running each process. Using pgrep with the effective-user filter and asking for the names gives a clean, precise list of what root is actually running right now. pgrep -u root -l searches for processes owned by the effective user root (user id 0) and prints the names of those processes. The -u root part targets processes running as root now, and -l makes the command print the process names, yielding a straightforward list of root-owned process names. Other options aren’t as precise or convenient. Using ps -ef | grep root can catch any process whose command line contains the string root, not necessarily processes owned by root, and you’d have to weed out the grep process itself. ps -U root -o pid,comm filters by the real user ID, which isn’t the same as the effective user ID that determines who is “running as” root in typical use. top -u root is interactive and shows dynamic usage statistics rather than a simple, static list of names. So the best choice is the one that directly filters by the effective root user and lists the process names in a concise, non-interactive format.

The key is filtering processes by the user identity that determines who is currently running each process. Using pgrep with the effective-user filter and asking for the names gives a clean, precise list of what root is actually running right now.

pgrep -u root -l searches for processes owned by the effective user root (user id 0) and prints the names of those processes. The -u root part targets processes running as root now, and -l makes the command print the process names, yielding a straightforward list of root-owned process names.

Other options aren’t as precise or convenient. Using ps -ef | grep root can catch any process whose command line contains the string root, not necessarily processes owned by root, and you’d have to weed out the grep process itself. ps -U root -o pid,comm filters by the real user ID, which isn’t the same as the effective user ID that determines who is “running as” root in typical use. top -u root is interactive and shows dynamic usage statistics rather than a simple, static list of names.

So the best choice is the one that directly filters by the effective root user and lists the process names in a concise, non-interactive format.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy