Tuesday, 31 January 2017

Troubleshooting file permissions with RHEL / CentOS 7

Let's say we have a file that we are unable to access as the 'apache' user.

The basics - checking the basic permissions:

ls -la /etc/apache/secret

-rw-r-----.  1 apache apache  128 Jan 31 14:16 encKey

Hear we can see that the 'apache' group has read permissions on the file and the 'apache' user / owner has read and write permissions.

So far everything looks ok - although we are still unable to access the file - so lets ensure there is not GUID / UID mismatches - to do this we can peform:

ls -lan /etc/apache/secret

-rw-r-----.  1 48 48  128 Jan 31 14:16 encKey

And then contrast the UID / GUID with:

id apache

uid=48(apache) gid=48(apache) groups=48(apache)

or alternatively:

cat /etc/passwd | grep apache

Again all looks good - so lets check the permissions on the parent directory:

ls -lan /etc | grep apache2
drwxr-xr-x.   5  0   0   4096 Jan 10 10:49 httpd

Again looks ok - the apache user has read and execute permissions.

Note: If you have recently added yourself into a group that has permission to the folder you will need to logout and back in again for changes to take effect.

The last part to check is ensure that any parent directories also have the appropriate permissions.


0 comments:

Post a Comment