A Permission denied error does not always mean the file needs broader permissions. The cause might be a parent directory, the file’s owner, or an access control that chmod does not change. Before reaching for chmod 777 , identify which user needs access and what operation they need to perform.
Read the mode before changing it
Start by checking the file, its owner, and the directory itself:
ls -l report.txt ls -ld /srv/www/site stat -c '%a %A %U:%G %n' report.txt
Enter fullscreen mode
Exit fullscreen mode
In ls -l output, the first character identifies the object type ( - for a regular file, d for a directory). The next nine characters describe permissions for the owner, group, and others, in that order. For example:
-rw-r--r-- 1 alice developers 128 Nov 11 10:00 report.txt
Enter fullscreen mode
Exit fullscreen mode
Here, Alice can read and write the file; members of the group and other users can read it.…