0

Is there a way to know the permissions for a given user (which is not the current user) for a specific file on Linux?

My question assume not switching user with su.

Fifi
  • 3,360
  • 2
  • 27
  • 53
  • The requirement to avoid switching to the user's account is problematic; I don't think there is a good way to avoid that. – tripleee Dec 11 '22 at 16:21

1 Answers1

0

This commands return 0, if youruser can read (-r), write (-w) or execute (-x) file or it returns 1 if youruser can't read, write or execute.

sudo -u youruser test -r /path/to/file
sudo -u youruser test -w /path/to/file
sudo -u youruser test -x /path/to/file
Garamoff
  • 84
  • 1
  • 6