Permission denied in 777 folder
This happens because there is a directory higher in the tree where you do not have execute permission. If a parent directory has no execute permission for some user, then that user cannot stat any subdirectories regardless of the permissions on those subdirectories.
Example:
$ ls -l cake
drwxr-xr-x 2 zanna zanna 4096 Jul 12 11:43 brownies
$ chmod 666 cake
$ ls -l cake/brownies
ls: cannot access 'cake/brownies': Permission Denied
Even though I am the owner of the directory 'brownies' and all users have permission to read and enter it, I can't access it if its parent directory has no execute permission.
It's better to use groups to manage permissions than give to give directories 777 permission. Are you sure you need to do that?
How to fix the problem in a more secure way:
Let's assume on /var/opt/gitlab
directory you have something like this:
drwxr-x--- 5 git git 4096 aug 14 17:30 gitlab
Add yourself and all the other users who need permission to the git group, for example:
sudo usermod -a -G john git
Users have to log out and back in for this to take effect. Even if write permission is needed on a subdirectory, you don't need to add it on a parent directory, by the way, so you don't have to use chmod
at all. You might want to change your subdirectory permissions to prevent anyone from being able to write to it:
chmod 775 /var/opt/gitlab/git-data/repositories/GL/www.git/custom_hooks
or
chmod o-w /var/opt/gitlab/git-data/repositories/GL/www.git/custom_hooks