ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 69 - XK0-005 discussion

Report
Export

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?

A.
find /var/log -type d -mtime +180 -print -exec rm {} \;
Answers
A.
find /var/log -type d -mtime +180 -print -exec rm {} \;
B.
find /var/log -type f -modified +180 -rm
Answers
B.
find /var/log -type f -modified +180 -rm
C.
find /var/log -type f -mtime +180 -exec rm {} \
Answers
C.
find /var/log -type f -mtime +180 -exec rm {} \
D.
find /var/log -type c -atime +180 -remove
Answers
D.
find /var/log -type c -atime +180 -remove
Suggested answer: C

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.

The other options are not correct commands for accomplishing the task. The find /var/log -type d -mtime +180 -print -exec rm {} ; command will search for directories (-type d) instead of files, and print their names (-print) before deleting them. This is not what the task requires. The find /var/log -type f -modified +180 -rm command is invalid because there is no such option as -modified or -rm for find. The correct options are -mtime and -delete, respectively. The find /var/log -type c -atime +180 -remove command is also invalid because there is no such option as -remove for find. Moreover, it will search for character special files (-type c) instead of regular files, and use access time (-atime) instead of modification time. Reference: find(1) - Linux manual page; Find and delete files older than n days in Linux

asked 02/10/2024
Nichal Maharaj
46 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first