Exam EX200 All QuestionsBrowse all questions from this exam
Question 5

SIMULATION -

Find the files owned by harry, and copy it to catalog: /opt/dir

    Correct Answer:

    To find all files owned by the user 'harry' and copy them to the directory /opt/dir, you can use the following set of commands: 1) Change to the /opt directory using the command cd /opt. 2) Create the directory if it does not already exist using mkdir -p dir. 3) Use the find command to locate all files owned by 'harry' and copy them to /opt/dir using find / -type f -user harry -exec cp -p {} /opt/dir/ \;. The -p option in the cp command preserves the attributes of the files. So, the complete set of commands will be: cd /opt; mkdir -p dir; find / -type f -user harry -exec cp -p {} /opt/dir/ \;.

Discussion
airphreak

find / -user Harry -type f -exec cp {} /opt/dir \;

Hayder_Alobaidi

find / -user hayder -type f 2>/dev/null -exec cp '{}' /opt/dir \;

brahmimedamine

find / -user harry -type f -exec cp -rpvf {} /opt/dir \; 2> /dev/null

Abhilashasok

# cd /opt/ # mkdir dir # find / -user harry -type f -exec cp -rfp {} /opt/dir/ \;

kenkct

find / -type f -user harry -exec cp {} /opt/dir \;

loloski

mkdir /opt/dir; find / -type f -user harry -exec cp -p '{ }' /opt/dir \;

thomasstate

why does it take time to process the command

MichaelChapoco

add -rf to the exec command

TheServant

May be its looking the entire '/' partition which might take time.

ertgrty

#mkdir /opt/dir #find / -type f -user Harry -exec cp {} -ar /opt/dir \;

ertgrty

sorry #mkdir /opt/dir #find / -type f -user Harry -exec cp -ar {} /opt/dir/ \;

Rahul95

#mkdir -p /opt/dir #find / -user harry -exec cp -rfp {} /opt/dir/ \; #ls ltr /opt/dir - to verify if files appeared or not

jahmad0730

What is the answer please? Syntax in the example is not working. [root@station /]# find / -user tom -exec cp {} /opt/dir/ \; cp: '/opt/dir/.bash_logout' and '/opt/dir/.bash_logout' are the same file cp: '/opt/dir/.bash_profile' and '/opt/dir/.bash_profile' are the same file cp: '/opt/dir/.bashrc' and '/opt/dir/.bashrc' are the same file cp: '/opt/dir/tom' and '/opt/dir/tom' are the same file cp: -r not specified; omitting directory '/home/tom' find: ‘/proc/8531/task/8531/fd/6’: No such file or directory find: ‘/proc/8531/task/8531/fdinfo/6’: No such file or directory find: ‘/proc/8531/fd/5’: No such file or directory find: ‘/proc/8531/fdinfo/5’: No such file or directory

tinythings

mkdir -p /opt/dir cp -nr --parents $(find / /home -xdev -user harry) /opt/dir

Mayowa15

after copy them to /opt/dir , how can I verify that is really copy to that? please. I run #cat /opt/dir but don't really see what make me sure. thanks

Ghassen0008

plz i need account exam topics plzzz <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ff8f7feececfaf1effceffcdff8f2fef6f3b1fcf0f2">[email protected]</a>

robust993

it's very easy # find / -user harry -exec cp {} /opt/dir/ \;

maxim_sk

for i in $(find / -user harry -type -f);do cp -rpvf $i /opt/dir;done

maxim_sk

i cannot edit, but the same as solution is: for i in $(find / -user harry);do cp -rpvf $i /opt/dir;done

eid

find / -user Harry -type f -exec cp -fp {}/opt/dir \; or cp -fp $(find / -user Harry -type f) /opt/dir

eid

find / -user Harry -type f -exec cp -fp /opt/dir \; or cp -fp $(find / -user Harry -type f) /opt/dir