-1

I'm using Amazon Linux. I have set global read permissions on a file, but I can't seem to access it as a normal user:

[myuser@mymachine ~]$ ls -al /usr/java/jboss/standalone/deployments/myproject.war/css/reset.css
ls: cannot access /usr/java/jboss/standalone/deployments/myproject.war/css/reset.css: Permission denied
[myuser@mymachine ~]$ sudo ls -al /usr/java/jboss/standalone/deployments/myproject.war/css/reset.css
-rwxrwxr-x 1 jboss jboss 771 Oct 29 18:51 /usr/java/jboss/standalone/deployments/myproject.war/css/reset.css
[myuser@mymachine ~]$ whoami
myuser

Notice that when I run "sudo" I am able to access it. I would like to keep the file owned by the jboss user. How can I get the file accessible to my (or anyone else's user) in read mode?

8

You need to check permissions of each element in the path, not just the file permissions. Each directory must have access 'x' (which means execute for files but traverse for directories) for the user wishing to run the command.

  • What if every directory on the path has the "r" permission set for everyone? Is there any other behavior that would explain what I'm seeing? – Dave Dec 7 '17 at 15:55
  • You can try "sequentially". Start by ls -al /usr then ls -al /usr/java and so on, to find where you have problems. You can have "extended ACLs" on some component of the path (see command lsattr) and even some specific to the filesystem you use, but this is far less likely than a pure base problem of read/execute rights missing. So first try component by component to pinpoint the problem. – Patrick Mevzek Dec 7 '17 at 16:02
  • You may have different results between ls and ls -l, see unix.stackexchange.com/a/150456/211833 – Patrick Mevzek Dec 7 '17 at 16:05
  • I traversed the directories as you suggested and found the directory where "ls -al" started giving "Permission denied" errors. However, taht directory does have global read permissions enabled. Do I need global "x" perms also enabled in order to view a file? – Dave Dec 7 '17 at 16:12
  • For ls -l, yes. – Patrick Mevzek Dec 7 '17 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.