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.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227

1 Answers1

2

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.

  • Hello @Scott. I ran `sudo chmod +x /var/log/mongosqld/`, and the case is closed! I am wondering, do you know why open requires execute? In my mind, that is a write permissions kind of thing. – Intrastellar Explorer May 10 '19 at 15:38
  • 1
    Our main resource on that is [Execute vs Read bit. How do directory permissions in Linux work?](https://unix.stackexchange.com/q/21251/23408) See also [Confused about the “execute” bit of a directory](https://unix.stackexchange.com/q/409597/23408) for some additional answers. – Scott - Слава Україні May 10 '19 at 18:12