nerdexam
CompTIACompTIA

XK0-005 · Question #555

XK0-005 Question #555: Real Exam Question with Answer & Explanation

The correct answer is C: find /var/log -type f -mtime +180 -exec rm {} \. The command that will accomplish the task of finding and removing all log files that were modified more than 180 days ago is find /var/log -type f -mtime +180 -exec rm {} ;. This command will use find to search for files (-type f) under /var/log directory that have a modification

System Management

Question

Due to low disk space, a Linux administrator finding and removing all log files that were modified more than 180 days ago. Which of the following commands will accomplish this task?

Options

  • Afind /var/log -type d -mtime +180 -print -exec rm {} \;
  • Bfind /var/log -type f -modified +180 -rm
  • Cfind /var/log -type f -mtime +180 -exec rm {} \
  • Dfind /var/log -type c -atime +180 -remove

Explanation

The command that will accomplish the task of finding and removing all log files that were modified more than 180 days ago is find /var/log -type f -mtime +180 -exec rm {} ;. This command will use find to search for files (-type f) under /var/log directory that have a modification time (-mtime) older than 180 days (+180). For each matching file, it will execute (-exec) the rm command to delete it, passing the file name as an argument ({}). The command will end with a semicolon (;), which is escaped with a backslash to prevent shell interpretation.

Topics

#find command#File system management#Command-line utilities#Log file cleanup

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions