20

Every time I log into a VM with root, su into a user account, and try to use screen it throws an error:

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

A Stack Overflow post said I needed to use script /dev/null to fix it, and it works, but it still doesn't explain why I need to type script /dev/null. I would like to understand what it does and why I need to type it.

  • 2
    > A Stack Overflow post said – it might be helpful if you also add a link to that post, maybe in a comment. – törzsmókus Apr 9 at 11:01
28

You cannot open /dev/pts/0 because it's owned by root, and after you su-ed into another user you're no longer able to open it via its path, but you're still able to use it via the opened handle to it, which was inherited from the parent process.

script /dev/null will create another pty, owned by the current user.

Anyways, that bug/limitation seems to have been fixed in recent versions of screen (eg. 4.99.0), which will correctly send the handle to the current terminal via the SCM_RIGHTS ancillary message on a unix domain socket, instead of sending just the name of the terminal and have the screen server try to open it (and fail). Same thing with tmux.

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.