How to use the Linux screen Command?

The Linux screen command is a very useful command. Usually, when we configure some cloud servers, once the network is disconnected, ssh is accidentally turned off, etc., the process is interrupted.

If we execute the command before running the screencommand, as long as the screen does not terminate itself. The sessions running inside it can be resumed. This is useful for users who log in remotely.

Common commands

Create a new session

$ screen -S lnmp

Leave current session temporarily

Press the Ctrl+A+Dkey to throw the current session to the background for execution, and it will return to the state when it was not in the screen

Resume session

If you have multiple sessions, you can list all the sessions, and then resume the specified session.

$ screen -r  

List all conversations

$ screen -ls 
There are screens on:
    28085.lnmp    (07/30/2017 04:17:19 PM)    (Detached)
    27423.lnmp    (07/30/2017 04:07:03 PM)    (Detached)
    780.lnmp    (07/03/2017 05:34:41 PM)    (Detached)
3 Sockets in /var/run/screen/S-root.

Resume specified session

$ screen -r lnmp 

Terminate the session

$ exit  #or Ctrl+D

To view screenall the functions of Linux screen Command, you can check the manual of the screen by using the Linux command man screen.

Leave a Comment