EX200 Exam QuestionsBrowse all questions from this exam

EX200 Exam - Question 36


SIMULATION -

Search files.

Find out files owned by jack, and copy them to directory /root/findresults

Show Answer
Correct Answer:

Discussion

12 comments
Sign in to comment
kenkct
Mar 2, 2022

sudo su mkdir /root/findresults (create folder if doesn't exist) find / -user jack -type f -exec cp {} /root/findresults/ \; ls /root/findresults (to verify)

sugisho
Jul 14, 2021

[root@abc ~]# find / -user jack -type f -exec cp -rp {} /root/findfiles/ \; find: ‘/proc/3337/task/3337/fdinfo/6’: No such file or directory find: ‘/proc/3337/fdinfo/7’: No such file or directory cp: cannot create regular file '/root/findfiles/': Not a directory cp: cannot create regular file '/root/findfiles/': Not a directory cp: cannot create regular file '/root/findfiles/': Not a directory cp: cannot create regular file '/root/findfiles/': Not a directory # find / -user jack -type f -exec cp -rp {} /root/findfiles/\; find: missing argument to `-exec'

wizojlo
Mar 11, 2024

I have heard from several people that they encountered a slightly modified version of this question, where it was required to include all files with SUID permission. Just add -perm u=s in the command to do so. One person also had this question made so that it must be made into a shell script. So take note ;)

ly01
Jul 10, 2024

this is wrong. "find / -perm /u=s" is the correct form. You have to escape it otherwise you will only find files that have only that mode bit set. From the man: -perm mode File's permission bits are exactly mode (octal or symbolic). Since an exact match is required, if you want to use this form for symbolic modes, you may have to specify a rather complex mode string. For example `-perm g=w' will only match files which have mode 0020 (that is, ones for which group write permission is the only permission set). It is more likely that you will want to use the `/' or `-' forms, for example `-perm -g=w', which matches any file with group write permission. See the EXAMPLES section for some illustrative examples.

cb52
Jan 4, 2022

mkdir -p /root/findresults find / -user jack -type f -exec cp -avrf {} /root/findresults/ \; ls -l /root/findresults

schwarztrinker
Mar 17, 2022

sudo -i for file in $(find / -user jack -type f); do cp $file /root/findresults/; done

rsebayang
Sep 10, 2020

find / -user jack -exec cp -rfp {} /root/findfiles/

cytron
Nov 9, 2020

You've forgotten the line termination \; Line should look like this find / -user jack -exec cp -rfp {} /root/findfiles/ \; # RHEL8

danielmaziarczyk
Dec 10, 2020

Also should be -type f "for files only" find / -user test -type f -exec cp -rp {} /root/findfiles/ \;

danielmaziarczyk
Dec 10, 2020

mistake should be: find / -user jack -type f -exec cp -rp {} /root/findfiles/ \

ms200
Jan 23, 2021

miss ; at the the end of the line

PTom
Mar 21, 2021

When you search for files only why do you need -r for cp command. The cp -r mean recursively copy directories. It's not an error but why?

Leepipes101
Mar 9, 2021

find / -user jack -exec cp -rfp /root/findfiles/ {} \;

Stachomir
Jul 6, 2021

cp -rfp $(find / -type f -user jack) /root/findfiles/

xXxM__JxXx
Mar 25, 2022

whats the negative impact if i don't include -type f in the command?

ANI_04
Oct 8, 2021

Can't we just do " find / -u jack -type f >> /root/findfiles " ?

sirasdf
Jul 28, 2022

No that won't copy the files that will just copy the results from the find command to a file. The solution is: find / -type f -user jack -exec cp -v {} /root/findresults \;

vira5489
Nov 24, 2021

useradd -m jack mkdir /root/findresults find / -u jack -type f -exec cp -rfp {} /root/findresults \;

ifbaibz
Dec 23, 2021

mkdir /root/findresults find / -user jack -type f -exec cp -a {}/root/findresults/\: ls /root/findresults

brahmimedamine
Feb 25, 2022

find / -user jack -type f -exec cp -rpvf {} /root/findresults\; 2> /dev/null