Sometimes in desperation, to test if my problem is not the permission problem I do:
sudo chmod -R 777 mydir/
In most cases it does not helps, and now I have two problems ;)
Files inside mydir/
had different permissions and owners each, and now I need to restore them to the original state.
Is there any smart way to recursive restore the permissions, except creating a backup copy? E.g.
command_to_save_the_permissions_somewhere mydir/
chmod -R 777 mydir/
command_to_restore_the_permissions_from_somewhere mydir/
BTW, any tips on debugging permission issues?
There's an easy way to back up and restore permissions amd ownerships of a directory tree using the ACL tools. It works even if you don't have ACLs enabled on the filesystem.
Most permission issues will cause a “permission denied” error message to appear somewhere, either on the console or in some log file.
A powerful tool to investigate file access issues is
strace
. It shows the system calls made by a process. The output can be difficult to understand, but it's relatively easy to see what files the program is trying to access and why it can or cannot find what it wants. Usage examples: