Which command lists processes owned by a given user with their PIDs and 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

Which command lists processes owned by a given user with their PIDs and names?

Explanation:
Listing processes owned by a specific user with their PIDs and names is best done with a tool that filters the process table by owner and can show the PID alongside the process name. The command pgrep -u <username> -l does exactly that: -u restricts the results to processes owned by the given user, and -l prints the process name (the command name) together with the PID. This yields a straightforward list where each line contains the PID and the corresponding process name, which matches the requested output. Other commands aren’t as direct for this exact need. ps can show PIDs and names if you tailor the output (for example, ps -u <user> -o pid,comm), but pgrep with -u and -l provides the concise, on-demand listing in a single command. Top is interactive and focused on real-time monitoring by default, and pkill is for signaling processes rather than listing them.

Listing processes owned by a specific user with their PIDs and names is best done with a tool that filters the process table by owner and can show the PID alongside the process name. The command pgrep -u -l does exactly that: -u restricts the results to processes owned by the given user, and -l prints the process name (the command name) together with the PID. This yields a straightforward list where each line contains the PID and the corresponding process name, which matches the requested output.

Other commands aren’t as direct for this exact need. ps can show PIDs and names if you tailor the output (for example, ps -u -o pid,comm), but pgrep with -u and -l provides the concise, on-demand listing in a single command. Top is interactive and focused on real-time monitoring by default, and pkill is for signaling processes rather than listing them.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy