What am I doing wrong (user files linux challenge

Hello

I have this command :

[steve@stapp02 ~]$ sudo find /home/usersdata/ -type f -user mark  -exec cp -R {}  /media \;
`` `
but still I see a message that im failing this challenge.
What do i do wrong ?

The tasks asks you to preserve the directory structure, which your command is not doing.

-R or -r stands for recursive copying. Since find is used with -type f, it only finds files (not directories), making the -R option unnecessary in this case. The command essentially attempts to copy files recursively, but since only files are being acted upon, it behaves like a standard copy for individual files. Therefore all the files are going into one directory.

Here you can see the difference between -r and --parents:

~/kodekloud/kke-file-copy/randomDirs$ ls
dir_1  dir_10  dir_11  dir_2  dir_3  dir_4  dir_5  dir_6  dir_7  dir_8  dir_9
~/kodekloud/kke-file-copy/randomDirs$ mkdir ../files ;find . -type f -exec cp --parents {} ../files  \;
al@Delos:~/kodekloud/kke-file-copy/randomDirs$ ls ../files/
dir_1  dir_10  dir_11  dir_2  dir_3  dir_4  dir_5  dir_6  dir_7  dir_8  dir_9
~/kodekloud/kke-file-copy/randomDirs$ find . -type f -exec cp -R {} ../files  \;
al@Delos:~/kodekloud/kke-file-copy/randomDirs$ ls ../files
dir_1   dir_2  dir_5  dir_8       file_10.txt  file_13.txt  file_16.txt  file_2.txt  file_5.txt  file_8.txt
dir_10  dir_3  dir_6  dir_9       file_11.txt  file_14.txt  file_17.txt  file_3.txt  file_6.txt  file_9.txt
dir_11  dir_4  dir_7  file_1.txt  file_12.txt  file_15.txt  file_18.txt  file_4.txt  file_7.txt

still no luck
I tried :

[steve@stapp02 usersdata]$ sudo find /home/usersdata/ -type f -user javed -exec cp --parents {} /offical \;

but still the challenge fails

I don’t think you need to use sudo. That would change the ownership of the files.