8

Is there a way I can open a new 'screen' session on my RHEL box as a non-root user? When I try to open a new screen using the 'screen' command as a non-root user, it fails and I get the following message:

Cannot open your terminal '/dev/pts/2' - please check.

I researched a little bit and found people suggesting to change the permissions on /dev/pts to grant the non-root user (who is trying to open the screen) a read/write access. Though it may work, it does not look like a neat solution. Is there a 'legal' way that allows a non-root user to open a screen session?

Edited : I have this issue on my RHEL 5.5, 6.2 and 6.5 machines. The screen version on all these boxes are 'Screen version 4.00.03 (FAU) 23-Oct-06'.

P.S:- I know that I can open a screen session as root and 'su' to start my command/process, but that is not what I am looking for.

7

This is a known problem, if you ssh as root somewhere and then su to become a normal user:

$ ssh root@server
# su -l anthon
$ screen 
Cannot open your terminal '/dev/pts/3' - please check.

It is e.g. described in these posts from 2005

The solution is to directly login as the user you want the screen session to run as.

  • I log in as normal user. Still cannot run screen. – codezombie Dec 11 '18 at 8:26
  • Maybe screen is not installed on your system, or some other unknown reason that causes that. Impossible to tell. You should post a new question (with a lot more information), and delete your comment. – Anthon Dec 11 '18 at 8:40
  • The VPS is managed, and the support says it is not supported on managed systems. Could I use a ready binary of screen or something? – codezombie Dec 11 '18 at 9:01
  • What part of you should post a new question do you not understand? Comments are not for posting questions and answers. Sigh.... screen runs as root (using setuid), so if you can arrange that on your managed system, just install the binary from the .deb or .rpm. In your case I would look at using tmux instead (which doesn't require running as root. – Anthon Dec 11 '18 at 9:41
  • Thanks I perfectly understand what you said but I’m pretty sure it will be set as duplicate if I post – codezombie Dec 11 '18 at 13:17
1

You have to use script /dev/null before using screen. After leaving screen you have to exit.

  • Or have it all in one command so you don't have to exit the script session: sudo -su user script -c bash /dev/null – basic6 Jun 27 '16 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.