exam questions

Exam XK0-005 All Questions

View all questions & answers for the XK0-005 exam

Exam XK0-005 topic 1 question 69 discussion

Actual exam question from CompTIA's XK0-005
Question #: 69
Topic #: 1
[All XK0-005 Questions]

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 {} \;
  • B. find /var/log -type f -modified +180 -rm
  • C. find /var/log -type f -mtime +180 -exec rm {} \
  • D. find /var/log -type c -atime +180 –remove
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
linux_admin
Highly Voted 1 year, 9 months ago
Selected Answer: C
The correct answer is C, "find /var/log -type f -mtime +180 -exec rm {} ;". This command will accomplish the task of finding and removing all log files that were modified more than 180 days ago. Here's a breakdown of the command: The find command is used to search for files and directories in a specific location, in this case, "/var/log". The -type f option is used to search only for regular files, excluding directories and other file types. The -mtime +180 option is used to select only files that have a modification time more than 180 days ago. The -exec rm {} \; option is used to execute the rm command on each file that matches the criteria specified in the previous options. The curly braces {} are replaced with the name of each file found and the backslash \; is used to end the command.
upvoted 7 times
linux_admin
1 year, 9 months ago
The other options, A and D, contain incorrect syntax or incorrect commands. Option B only has the "find" and "rm" commands and is missing the options to specify the type of files to search for and the time frame for modification. Option D uses the incorrect option "-remove" instead of "-exec rm {} ;".
upvoted 2 times
...
...
Nvoid
Highly Voted 1 year, 11 months ago
Selected Answer: C
C is Correct.
upvoted 7 times
...
bc1235813
Most Recent 8 months ago
Selected Answer: C
"A" is going after directories older than 180 days, "B" & "D" are gibberish - "C" would be right if the semicolon was there at the end of the command.
upvoted 1 times
...
e418137
9 months ago
Selected Answer: A
A. The 'find' command with its '-exec' option requires an escaped semi-colon, '\;' (B) There is no predicate, modified. (C) This would work just as well as answer, A, if the command ended with a semi-colon. (D) Nonsense.
upvoted 1 times
...
BryanSME
11 months ago
THE CORRECT OPTION IS C. I've tested this, but used 1600 days so found only one file that old, used option C and it deleted it only, results below: # find /var/log -type f -mtime +1600 /var/log/anaconda/syslog <<<<<<<<<<< found this file over 1600 days old-didn't want to remove anything important # find /var/log -type f -mtime +1600 -exec rm {} \; <<<<<<<<<<< Executed option C # find /var/log -type f -mtime +1600 <<<<<<<<<<< Ran command again and /var/log/anaconda/syslog is no longer present
upvoted 3 times
...
Damon54
1 year, 3 months ago
in question C ; end the command is not present , the command not work ! A is correct ?
upvoted 1 times
...
KnifeClown1
1 year, 9 months ago
Selected Answer: C
The correct command to accomplish this task is C: This command uses the find utility to search for files in the /var/log directory and its subdirectories. The -type f option specifies to search only for files (not directories), and the -mtime +180 option specifies to search for files that were modified more than 180 days ago. The -exec rm {} \; option specifies to execute the rm command on each file found by the find command. The {} characters are a placeholder for each file that is found, and the \; at the end of the command is used to terminate the -exec option. Note that the other options listed are incorrect and should not be used.
upvoted 2 times
...
Ckl22
1 year, 10 months ago
Selected Answer: C
The answer is C
upvoted 4 times
...
MissAllen
2 years ago
Disagree. Correct answer should be C. The question refers to removing log "files". The type option for find needs -f for files.
upvoted 7 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago