Note: I have read and think I understand what's written in Execute vs Read bit. How do directory permissions in Linux work?
But I may be missing where in the hierarchy that execute directory permission needs to be set to cd into a directory.
Specifically, I am trying to make the postgres log group-readable so that I can look at the execution log. FWIW, though it's not part of my question, I edited postgresql.conf to set log_file_mode = 0640.
Note: PGDATA=/opt/local/var/db/postgresql13/defaultdb.
so now, let's cd $PGDATA/log
Permission error.
OK, sudo su postgres then chmod 750 $PGDATA/log
I have now set the execute bit on the log directory.
cd $PGDATA/log
Permission error.
Turned out that I needed to set the execute on the parent of $PGDATA/log, i.e. chmod 750 $PGDATA . Then cd $PGDATA/log worked.
I understand the logic behind requiring x set on $PGDATA if I was doing say ls $PGDATA and looking at what is in $PGDATA. But I never tried to, I was going directly into $PGDATA/log.
So, is it correct to say that to cd <somedir> you really execute permission on somedir's parent, not just the directory itself?
ls "$PGDATA"and look at the names of the things in$PGDATA, you need *read* permission on$PGDATA. In fact, to dols "$PGDATA"and look at only the names of the things in$PGDATA, read permission on$PGDATAis *all* you need. To dols -l "$PGDATA"and look at the names and attributes of the things in$PGDATA, you need read and execute permission on$PGDATA. – G-Man Says 'Reinstate Monica' Apr 05 '22 at 05:46