EX200 Exam QuestionsBrowse all questions from this exam

EX200 Exam - Question 78


SIMULATION -

1. Find all sizes of 10k file or directory under the /etc directory, and copy to /tmp/findfiles directory.

2. Find all the files or directories with Lucy as the owner, and copy to /tmp/findfiles directory.

Show Answer
Correct Answer:

To accomplish the tasks specified in the question, you need to use the 'find' command to locate the relevant files and then copy them to the '/tmp/findfiles' directory. Here are the correct commands for each task: 1. To find all files or directories of 10k size under the '/etc' directory and copy them to '/tmp/findfiles' directory, use: 'find /etc -size 10k -exec cp -a {} /tmp/findfiles \;'. The '-a' option is used with 'cp' to preserve file attributes, including ownership and permissions. 2. To find all files or directories owned by the user 'lucy' and copy them to '/tmp/findfiles' directory, use: 'find / -user lucy -exec cp -a {} /tmp/findfiles \;'. Again, the '-a' option is used to ensure that the file attributes are preserved during the copy operation.

Discussion

4 comments
Sign in to comment
jjknow85
Nov 11, 2021

#mkdir /tmp/findfiles # find /etc -size 10k -exec cp -r {} /tmp/findfiles \; # find / -user lucy -exec cp -r {} /tmp/findfiles \;

ly01
Jul 13, 2024

I would use cp -a to preserve the ownership.

Frenzy
May 9, 2022

mkdir /tmp/findfiles cp $(find /etc -size 10k) /tmp/findfiles/ cp $(find / -user lucy) /tmp/findfiles/

STFN2019
Sep 23, 2021

Why not just use the following: find /etc -size 10k > /tmp/findfiles find / -user lucy >> /tmp/findfiles

atilade
Sep 26, 2021

/tmp/findfiles is a directory. You can only append to files

reemartan
Oct 16, 2021

This is just redirecting your command output to a file, but not copying the files to a directory

mattd81
Apr 30, 2022

How would you check to see what is in the directory to verify your search?