Which of the following commands look through the currently running processes, and list the
process IDs that match the selection criteria to stdout?
Each correct answer represents a complete solution. Choose all that apply.
A.
top
B.
pkill
C.
sort
D.
pgrep
Explanation:
pgrep looks through the currently running processes and lists the process IDs that match the
selection criteria to stdout. All the criteria have to match. pkill is a tool that looks up or signals
processes based on name and other attributes. Pkill will send the specified signal (by default
SIGTERM) to each process instead of listing them on stdout.
Answer option A is incorrect. The top command is used to produce a frequently-updated list of
processes. By default, the processes are ordered by percentage of CPU usage, with only the “top”
CPU consumers shown. This command shows how much processing power and memory are
being used, as well as other information about the running processes. The following figure
demonstrates the output of the top command:Answer option C is incorrect. The sort command is used to print the lines of its input or
concatenation of all files listed in its argument list in sorted order. Sorting is done based on one or
more sort keys extracted from each line of input. By default, the entire input is taken as the sort
key. The blank space is taken used as the default field separator in the output of the sort
command.
The -r flag, however, reverses the sort order. For example, the ls -s | sort -nr command will sort
the directories of the root directory in reverse order of size.