"screen is terminating" for non-root

When I try to run screen as a non-root user I get:

screen

[screen is terminating]

immediately, though it works fine for root

ls -alh /usr/bin/screen
-rwxr-sr-x 1 root screen 465K Jun  9 20:30 /usr/bin/screen

When googling around I noticed a mention of /etc/fstab, here is mine:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/md1        /       ext4    errors=remount-ro       0       1
/dev/md2        /home   ext4    defaults        1       2
/dev/sda3       swap    swap    defaults        0       0
/dev/sdb3       swap    swap    defaults        0       0
proc            /proc   proc    defaults                0       0
sysfs           /sys    sysfs   defaults                0       0
tmpfs           /dev/shm        tmpfs   defaults        0       0
devpts          /dev/pts        devpts  defaults        0       0

This on a freshly installed centos 7 on a dedicated server accessed through ssh ( TTY is pts )

Any help would be appreciated.

screen -ls    
No Sockets found in /var/run/screen/S-user.

ls -la /var/run/screen/S-user
total 0
drwx------ 2 user user 40 Jul 10 18:23 .
drwxrwxr-t 4 root     screen   80 Jul 10 17:59 ..

Solution 1:

I had this issue on Dedicated CentOS 7 server, and came across the fix described in this bug report: bugs.centos.org/view.php?id=7395

That was a fine solution on the Dedicated to add gid=5 to devpts in fstab. screen now works as expected for all users.

However, I ran across this thread as I was trying to solve the issue on an OpenVZ container of CentOS 7. As there isn't a way to edit the fstab for the server (as far as I could find), I found the following work-around fixed it.

I figured I would drop back by this way and see if it might help anyone else out. (Albeit isn't a very pretty way of doing it.)

In terminal:

chmod u+s /usr/bin/screen
chmod 755 /var/run/screen

Solution 2:

Ensure no other screen is using that device

This can be achieved with How can I determine what process has a file open in Linux? :

sudo lsof /dev/ttyS0

And then kill that process if that is the case.

For some reason, under this condition, sudo screen can still access the device, but then that connection will miss characters, which are consumed by the other screen.

Ensure the user has read and write permission to the file

E.g. on Ubuntu you want to add the user to the dialout group: https://askubuntu.com/a/133244/52975