How to use the screen command: 2-Minute Linux Tips


Hi, this is Sandra Henry-Stocker, author of
the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the screen command – a command that allows
you to detach an SSH session and then reconnect to it.
The benefit of the screen command is that it ensures that any disruptions to your ssh
session will not cause the process that you’re running to be terminated. You can start the
process, detach the session and know that the process will continue running.
Let’s look at an example. To start a screen session, just type screen.
Notice how the command clears your screen. With the screen session started, I’m going
to run a script that will take a very long time to finish.
When you’re ready to detach from your screen session, type Ctrl+AD (hold the control key
while pressing A and then D). To reattach, use the command screen -r.
When you’re ready to close a screen session, use Ctrl+D or type exit.
This example shows only the simplest use of the screen command. You can open multiple
sessions and even give screen sessions names so that the various tasks that you’re running
in the sessions are easier to manage. To start a named screen session, type screen
-S followed by the name you want to give the session.
Once you detach with Ctrl+AD, you can list your sessions with screen -ls and
reattach with a command like screen -r longloop. That’s your Linux tip for the screen command.
If you have questions or would like to suggest a topic, please add a comment below. And don’t
forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be
sure to follow us on Facebook, YouTube and NetworkWorld.com.

, , , , , , , , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *