A system administrator is troubleshooting a log rotation failure for the file /var/log/syslog. The rotation script cannot access the file because it is held open by a running process. Which of the following commands will most effectively identify the command, process ID (PID), and user associated with the process that has /var/log/syslog open?
The correct command is lsof /var/log/syslog. The lsof (List Open Files) command is used to display information about files that are open by various processes. When given a file path as an argument, it will list all processes that have that specific file open, along with details like the PID, user, and command name. The ps -ef | grep /var/log/syslog command is incorrect because ps lists running processes, but grepping for a file path is not a reliable way to find which process has a file open, as the file path is not typically part of the process's command line information. The file /var/log/syslog command is used to determine the type of a file (e.g., ASCII text, binary), not which process is using it. The stat /var/log/syslog command displays detailed file metadata like size, permissions, and timestamps, but does not show process-related information.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the `lsof` command do?
Open an interactive chat with Bash
Why is `ps -ef | grep` not effective for finding processes holding files?
Open an interactive chat with Bash
What is the difference between `file`, `stat`, and `lsof` commands?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .