Cannot make directory ‘/var/run/screen/S-apache’: Permission denied

Hello! Im trying to create a screen folder for the user apache, Not root. But it seems to fail, I have no idea on how to fix this issue. I only get the error: Cannot make directory ‘/var/run/screen/S-apache’: Permission denied

Im using Cent OS 7

There may be various possible reasons.

2 common reasons:

screen is not installed correctly.

You may try using another non-root user to verify whether screen is installed and works correctly. It makes use of the setgid permission and these file/dir permissions should usually be as follows.

screen binary’s group should be ‘screen’ and screen should have the ‘-s-‘ flag:

$ getfacl $(which screen)
getfacl: Removing leading '/' from absolute path names
# file: usr/bin/screen
# owner: root
# group: screen
# flags: -s-
user::rwx
group::r-x
other::r-x

/var/run/screen dir group is ‘screen’:

$ ls -lha /var/run/ | grep screen
drwxrwxr-x   3 root           screen           60 Aug 28 18:59 screen

If there are not like this, you may manually set them or re-install screen.

SELinux blocks screen.

Check the log after you tried screen by user ‘apache’:

# tail /var/log/audit/audit.log

and see whether it shows some messages related. If so, relax SELinux for the permissions.

Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *