nerdexam
CompTIA

XK0-005 · Question #1776

A Linux systems administrator needs to stop an application and identify which files the application has opened in the /app directory. Which of the following is the best command to use?

To identify files opened by processes in a specific directory, the lsof command is the most effective tool, as it lists open files and the processes that hold them. Piping its output to grep allows filtering for a specific path.

Troubleshooting

Question

A Linux systems administrator needs to stop an application and identify which files the application has opened in the /app directory. Which of the following is the best command to use?

Options

  • Alsof | grep /app
  • Btop | grep /app
  • Cps -ef | grep /app
  • Dls -o /app | grep open

Why each option

To identify files opened by processes in a specific directory, the `lsof` command is the most effective tool, as it lists open files and the processes that hold them. Piping its output to `grep` allows filtering for a specific path.

Alsof | grep /app
Btop | grep /app

The `top` command displays process activity in real-time, showing CPU and memory usage, but it does not list files opened by processes.

Cps -ef | grep /app

The `ps -ef` command lists all running processes and their full command lines, but it does not directly show which files those processes have open.

Dls -o /app | grep open

The `ls -o /app` command lists directory contents with owner information, but it does not show which files are actively opened by processes.

Concept tested: Identifying open files by process

Source: https://man7.org/linux/man-pages/man8/lsof.8.html

Topics

#lsof command#Open file identification#Process monitoring#Linux utilities

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice