Several things have to line up before “being in the group” actually turns into “can read the file.”
Here are the common gotchas that produce a Permission denied even though the long listing looks fine:
────────────────────────────────────────────────────────────────────────
- The shell (or process) doesn’t yet “know” the new group
────────────────────────────────────────────────────────────────────────
• Group membership is captured once, at login.
• If the user was added to perforce after they logged in, every process they already have running still carries the old credential set.
Check:
id # does “perforce” appear?
Fix: log out and back in, or use newgrp perforce / sg perforce -c "cat log".
────────────────────────────────────────────────────────────────────────
2. One of the parent directories blocks access
────────────────────────────────────────────────────────────────────────
To open /path/to/log, the kernel must:
– traverse /, path/, path/to/, etc.
– open the file.
For each directory in the path the user needs the execute (x) bit and—depending on what they do—often the read (r) bit.
Example:
drwx------ root root … /var
drwxr-x--- perforce perforce … /var/perforce
-rw-r----- perforce perforce … /var/perforce/log
A perforce-group user will still fail because /var has no x for them.
Check:
ls -ld / /var /var/perforce
Fix: grant group x (and optionally r) on the necessary directories, e.g.
chmod g+rx /var
────────────────────────────────────────────────────────────────────────
3. POSIX ACLs override the traditional bits
────────────────────────────────────────────────────────────────────────
Modern filesystems can carry Access-Control Lists that add or subtract rights beyond the simple rwx set.
Check:
getfacl log
If you see something like:
group:perforce:---
that ACL masks out the read bit.
Fix with setfacl -x g:perforce log (or adjust accordingly).
────────────────────────────────────────────────────────────────────────
4. Mandatory access controls (SELinux, AppArmor, …)
────────────────────────────────────────────────────────────────────────
When SELinux is in enforcing mode, the discretionary permissions may succeed yet SELinux policy denies the operation.
Check quickly:
getenforce # “Enforcing”?
ausearch -m avc -ts recent_or /var/log/audit/audit.log
If you see an AVC deny about that file, it’s an SELinux rule, not Unix permissions.
Fix: adjust the context (restorecon, chcon) or tweak policy.
────────────────────────────────────────────────────────────────────────
5. Special mount or filesystem options
────────────────────────────────────────────────────────────────────────
NFS exports, CIFS shares, nosuid, nodev, or root_squash options can also interfere, though they’re less common for a simple read.
────────────────────────────────────────────────────────────────────────
Quick diagnostic checklist
────────────────────────────────────────────────────────────────────────
id # am I in perforce right now?
ls -l log # still -rw-r----- ?
ls -ld $(dirname "$(realpath log)") # walk up the tree, look for x
getfacl -a log # extra ACLs?
getenforce # SELinux status
Whichever of those tests fails will point you to the underlying cause of the Permission denied.