Which of the following commands would be BEST to use to accomplish this task?
A Linux engineer has been notified about the possible deletion of logs from the file /opt/app/logs.
The engineer needs to ensure the log file can only be written into without removing previous entries.
Which of the following commands would be BEST to use to accomplish this task?
A . chattr +a /opt/app/logs
B . chattr +d /opt/app/logs
C . chattr +i /opt/app/logs
D . chattr +c /opt/app/logs
Answer: A
Explanation:
The command chattr +a /opt/app/logs will ensure the log file can only be written into without removing previous entries. The chattr command is a tool for changing file attributes on Linux file systems. The +a option sets the append-only attribute, which means that the file can only be opened in append mode for writing. This prevents the file from being modified, deleted, or renamed. This is the best command to use to accomplish the task. The other options are incorrect because they either set the wrong attributes (+d, +i, or +c) or do not affect the file at all (-a).
Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 11: Managing Files and Directories, page 357.
Latest XK0-005 Dumps Valid Version with 136 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund