I can login to the server terminal with username and password. But I can't run the screen command. It says Must be connected to a terminal while I ran this screen -R newNodeServer.

I found an answer at Ask Ubuntu: What does the script /dev/null do?, but if I run the command script /dev/null according to that answer, will the running server, websites, and applications be affected?

I am going to run some artisan commands for Laravel in screens. Such as php artisan queue and php artisan websockets:serve

  • I myself would be asking the more obvious question Why, if I am logged in to a terminal, is the computer saying that I am not connected to a terminal?.
    – JdeBP
    Dec 10 '19 at 11:05
  • @JdeBP, That's I already running with the terminal
    – test team
    Dec 10 '19 at 13:04
  • I cannot make any sense of that sentence.
    – JdeBP
    Dec 10 '19 at 13:42
  • @JdeBP because older versions of screen will try to open the current terminal via its path, and that may not work on Linux: it's the same problem as with su other_user -c 'cat /dev/stdout' or su other_user -c 'cat /dev/tty', etc.
    – mosvy
    Dec 10 '19 at 15:54
  • 4
    Maybe check the answer to that same Q on this site: What does 'script /dev/null' do?
    – mosvy
    Dec 10 '19 at 15:57

My best guess here is:

  1. @testteam is trying to run screen command and getting screen complaining about not being able to open terminal.
  2. In the answer linked, solution mentioned is to use script /dev/null and that should resolve the issue.
  3. @testteam is wondering if that's going to affect any servers running on the machine (probably in the screen session).

This answer has very good explanation what script command is going to do and why screen is complaining:

Why this works is invoking script has a side effect of creating a pseudo-terminal for you at /dev/pts/X. This way you don't have to do it yourself, and screen won't have permission issues - if you su from user A to user B, by directly invoking screen you try to grab possession of user A's pseudo-terminal. This won't succeed unless you're root.

So the fact that script solves the issue with screen is basically side effect. I'm guessing that you want to run some node.js app in the screen session. The fact that you created pts device and used script for that should not affect servers or (web)apps running inside screen session.

  • I am going to use the screen for artisan commands. So see the updated question, please
    – test team
    Dec 10 '19 at 16:09
  • And what's about the last part of the linked answer(serverfault.com/a/255531/86410) "This won't succeed unless you're root. That's why you see the error message."?
    – test team
    Dec 10 '19 at 16:14
  • Newer version of screen are perfectly able to "grab posession" of the terminal without being root. I don't think that the answers you link to do such a great job explaining why older versions of screen aren't able to do it.
    – mosvy
    Dec 10 '19 at 16:16

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