Keeping Commands Running with GNU Screen

Learn how to keep commands running in the CLI with GNU Screen.

We may occasionally find ourselves in situations where we want to keep something running for a longer period of time, even when we close our shell session. We might need a file to download, a program to compile, or a complex installation process to finish. We’ve already seen how to do background tasks, but often this isn’t enough.

Of the methods we can use to keep long-running tasks going, the GNU Screen program is one of the easiest and most flexible options. The screen is a terminal multiplexer, meaning that it creates virtual terminal sessions on top of our actual terminal session. We can start tasks in these sessions, detach from them, and they’ll run in the background, even if we log out. We can also use screen to run multiple programs simultaneously and even split the terminal window into multiple panes so we can run programs side by side.

Let’s explore a couple of uses for screen. The most basic usage is to use screen to run a long-running process in the background and have it persist even when we close our terminal window. To see how this works, let’s run the top command with screen:

$ screen top

Get hands-on with 1200+ tech skills courses.