I've just written a simple bash file to copy a full directory to my home directory to avoid permission problems when tracking it with git.
The script looks as follows:
#!/bin/bash working_directory="/opt/lampp/htdocs/vocab/" target_directory="." cp -R $working_directory $target_directory
The script is owned by my local username "peter".
-rwxrwx--- 1 peter peter 123 Sep 11 11:02 update.sh
During the copy process I get an error that files of the folder "/opt/lampp/htdocs/vocab/files" cannot be copied due to permission restrictions.
ls -l /opt/lampp/htdocs/vocab/ returns
drwxr-xr-x 2 root root 4096 Sep 10 22:59 css drwxrwxrw- 2 www-data www-data 4096 Sep 11 11:06 files drwxr-xr-x 2 root root 4096 Aug 17 21:33 html -rw-r--r-- 1 root root 918 Sep 3 08:28 index.html ...
As you can see the problem causing directory "files" is neither possessed by peter nor its group contains peter. I checked this running the command
Why can I copy all directories and files except "files"? On the one hand peter does not have the permission to do any stuff with "files", because he is not the owner and does not belong to the group, but on the other hand all other directories are owned by root - this actually the same case. peter does not belong to root, but he somehow has no problem to copy those files and dirs. Why?