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)
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 ;)
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.
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 \;
[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'
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
...
...
...
...
...
...
Log in to ExamTopics
Sign in:
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.
kenkct
Highly Voted 2 years, 9 months agowizojlo
Most Recent 8 months, 4 weeks agoly01
4 months, 3 weeks agoschwarztrinker
2 years, 8 months agobrahmimedamine
2 years, 9 months agocb52
2 years, 11 months agoifbaibz
2 years, 11 months agovira5489
3 years agoANI_04
3 years, 1 month agosirasdf
2 years, 4 months agosugisho
3 years, 4 months agoStachomir
3 years, 5 months agoxXxM__JxXx
2 years, 8 months agoLeepipes101
3 years, 9 months agorsebayang
4 years, 2 months agocytron
4 years agodanielmaziarczyk
3 years, 12 months agodanielmaziarczyk
3 years, 12 months agoms200
3 years, 10 months agoPTom
3 years, 8 months ago