Menu Close

Screen: Background Terminal in Linux

One of my favorite command line utilities is screen, which allows you to run terminal windows in the background. This is helpful for running commands on a remote server or if you have a command you use often. Your command history for named screens is saved, which can speed up routine tasks.

Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).

http://manpages.ubuntu.com/manpages/eoan/en/man1/screen.1.html

Screen is a command line utility for Linux, which allows you to run programs in a sub-shell that can be detached and reattached, as needed. This is especially useful if you want to run a program, without leaving your terminal window open, such as through an SSH session.

Creating a Screen

In a terminal window type:

screen

A new screen will be created, which just looks like a new terminal window. Typing exit will close the screen.

To create a named screen, type:

screen -S "my-window"

This will create a named screen that you can reattach later. Type a command, use as ls, so you can see it saves what is going on when the screen is detached.

To detach a screen press keys Ctrl + a, d . This will detach the screen and keep it open in the background.

To see detached screens type:

screen -list

This will list all detached screens, along with the name you can use to reattach.

To reattach the “my-window” screen, type:

screen -r "my-window"

You will then be able to see and interact with the re-attached screen. If you only have one screen detached, you can leave the name off, such as:

screen -r

I hope you find this utility as useful as I do. It can be useful for node.js development servers and watchers will continue to run in the background in a detached screen.

Posted in Linux

Related Posts

Leave a Reply

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