18

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 ..
Rob
  • 669

3 Answers3

16

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
Sun
  • 6,318
Csnap
  • 260
  • This answer solved the issue for me, Ubuntu 18.04 running on openvz container – aafirvida Dec 27 '18 at 22:49
  • As the mentioned link doesn't work anymore (neither the one in the Wayback machine or the original one), I'm afraid I don't fully understand the answer. However, I made the chmod permission changes, added my user to the screen group, and it works again. – Tobias Oct 04 '23 at 13:20
  • FYI: The solution at the link was to add the parameter gid=5 into the devpts line in the server's /etc/fstab. OpenVZ containers don't allow you to make this modification, so I was prefacing my answer with that information to help make the distinction in solutions. – Csnap Oct 11 '23 at 14:14
5

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

-3

It might be an errors in your config file

~/.screenrc

Try to check it or create dimmy one.