nerdexam
CompTIA

XK0-005 · Question #555

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?

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…

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

How the community answered

(41 responses)
  • A
    7% (3)
  • B
    17% (7)
  • C
    73% (30)
  • D
    2% (1)

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 Practice