exam questions

Exam EX200 All Questions

View all questions & answers for the EX200 exam

Exam EX200 topic 1 question 37 discussion

Actual exam question from RedHat's EX200
Question #: 37
Topic #: 1
[All EX200 Questions]

SIMULATION -
Search files.
Find out files owned by jack, and copy them to directory /root/findresults

Show Suggested Answer Hide Answer
Suggested Answer: See explanation below.
mkdir/root/findfiles
find / -user jack -exec cp -a {} /root/findfiles/ \; ls /root/findresults

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
kenkct
Highly Voted 2 years, 9 months ago
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)
upvoted 9 times
...
wizojlo
Most Recent 8 months, 4 weeks ago
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 ;)
upvoted 3 times
ly01
4 months, 3 weeks ago
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.
upvoted 1 times
...
...
schwarztrinker
2 years, 8 months ago
sudo -i for file in $(find / -user jack -type f); do cp $file /root/findresults/; done
upvoted 2 times
...
brahmimedamine
2 years, 9 months ago
find / -user jack -type f -exec cp -rpvf {} /root/findresults\; 2> /dev/null
upvoted 1 times
...
cb52
2 years, 11 months ago
mkdir -p /root/findresults find / -user jack -type f -exec cp -avrf {} /root/findresults/ \; ls -l /root/findresults
upvoted 2 times
...
ifbaibz
2 years, 11 months ago
mkdir /root/findresults find / -user jack -type f -exec cp -a {}/root/findresults/\: ls /root/findresults
upvoted 1 times
...
vira5489
3 years ago
useradd -m jack mkdir /root/findresults find / -u jack -type f -exec cp -rfp {} /root/findresults \;
upvoted 1 times
...
ANI_04
3 years, 1 month ago
Can't we just do " find / -u jack -type f >> /root/findfiles " ?
upvoted 1 times
sirasdf
2 years, 4 months ago
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 \;
upvoted 1 times
...
...
sugisho
3 years, 4 months ago
[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'
upvoted 3 times
...
Stachomir
3 years, 5 months ago
cp -rfp $(find / -type f -user jack) /root/findfiles/
upvoted 1 times
xXxM__JxXx
2 years, 8 months ago
whats the negative impact if i don't include -type f in the command?
upvoted 1 times
...
...
Leepipes101
3 years, 9 months ago
find / -user jack -exec cp -rfp /root/findfiles/ {} \;
upvoted 1 times
...
rsebayang
4 years, 2 months ago
find / -user jack -exec cp -rfp {} /root/findfiles/
upvoted 1 times
cytron
4 years ago
You've forgotten the line termination \; Line should look like this find / -user jack -exec cp -rfp {} /root/findfiles/ \; # RHEL8
upvoted 2 times
danielmaziarczyk
3 years, 12 months ago
Also should be -type f "for files only" find / -user test -type f -exec cp -rp {} /root/findfiles/ \;
upvoted 2 times
danielmaziarczyk
3 years, 12 months ago
mistake should be: find / -user jack -type f -exec cp -rp {} /root/findfiles/ \
upvoted 4 times
ms200
3 years, 10 months ago
miss ; at the the end of the line
upvoted 1 times
PTom
3 years, 8 months ago
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?
upvoted 4 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 ...