EX200 Exam QuestionsBrowse all questions from this exam

EX200 Exam - Question 106


SIMULATION -

Locate all the files owned by ira and copy them to the / root/findresults directory.

Show Answer
Correct Answer:

To locate all files owned by a user named 'ira' and copy them to the /root/findresults directory, you can use the 'find' command along with 'cp' and 'exec' options. Follow these steps: 1. Create the directory /root/findresults if it doesn't already exist using 'mkdir -p /root/findresults'. 2. Use the command 'find / -user ira -exec cp -a {} /root/findresults \\;'. This command will search the entire filesystem for files owned by 'ira' and execute the cp command to copy each found file to the /root/findresults directory, preserving attributes and links using the '-a' option.

Discussion

2 comments
Sign in to comment
Stachomir
Jul 9, 2021

cp -rp $(find / -user ira -type f) /root/findfiles

STFN2019
Sep 28, 2021

Thx Stachomir, that's really helpful

mattd81
Jun 13, 2022

find / -user ira -type f -exec cp {} /root/findfiles \;