1

I am having a really tough time understand user/group permissions. I have spent hours reading and trying things. Here is what I have:

Directories Permissions

Input 1: ls -lhd

Output 1:

/var/log: drwxrwxr-x 11 root syslog 4.0K May 10 01:59 .

/var/log/mongosqld: drw-rw-r-- 2 mongosqld logstash 4.0K May 10 03:37 .

Note: I set this up using chown and chgrp.

File Permissions

Input 2: ls -lh

Output 2:

/var/log/mongosqld:

total 12K
-rw-rw-r-- 1 mongosqld logstash 1.4K May 10 03:43 mongosqld.log

Groups:

Input: groups logstash mongosqld

Output:

logstash : logstash
mongosqld : users logstash

My Question

When I try to open a file as the mongosqld user, it tells me open /var/log/mongosqld/mongosqld.log: permission denied. Where I am going wrong.

1

You can’t access anything in /var/log/mongosqld (unless you’re running as root) because it (the directory) doesn’t have any execute bits set.

0

To open a file, I guess you mean you want to look at it's content.

The open function is not what you want for that. Do man open or open -h to learn what open does.

To look at a file you can do :

  • head or tail to look at it's first (last) lines

  • less (less is more) to look at it's content (it's a "pager")

or you can edit it in an editor such as vim or emacs etc..

  • How does this explain the permission problem described in the question? – Stephen Kitt May 10 at 7:21
  • The user, after a long digression on permissions, opened a file... How ? We don't even have the input... or do we ? I thought the "open /var/log/mongosqld/mongosqld.log" provided might have been part of the input, so provided classic advices on how to open a file... – Samusz May 10 at 21:38
  • The “open /var/log/mongosqld/mongosqld.log: permission denied” indicates that the user knows how to open a file, but doesn’t have the permission to do so. – Stephen Kitt May 11 at 4:24

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.