The Basics of using the Linux screen command

Not too long ago, I learned about the magic of the screen command in Linux. It has saved countless hours of staring at progress bars (or lack thereof) in the terminal window.

The screen command tool is used for running commands in Linux and then exiting the same open terminal to run those commands in the background. This is very useful when you need to walk away from your computer or allow commands to run for an extended period of time.

What Linux screen is used for

The screen tool can  be used to run commands in separate terminal windows. Later you can resume the different screens to see live code running or things processing in the background. This can be used for things like running a crypto miner, plotting with Chia, or using rclone to move/copy files to the cloud.

How to install Linux screen

On Ubuntu/Debian, in a terminal window, use sudo apt update && sudo install screen. This will update your repositories and install the screen tool.

How Linux screen is used

The simplest way to use the command is to simply type screen. This will open a new screen window and allow you to type commands further.

My favorite way of using it is to just add screen to any existing command. i.e. screen rclone move ... ... -P   and then let it run

Resuming a screen session

I had trouble with this in the beginning. It should have been self-explanatory, but took some getting used to.

Type screen -r to list any current sessions. To get into a specific screen, type screen -r ##### with the number signs being the right one.

nick@canary:~$ screen -r
There are several suitable screens on:
        32032.pts-3.canary      (07/06/2021 01:02:24 PM)        (Detached)
        26562.pts-3.canary      (07/06/2021 12:52:47 PM)        (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
nick@canary:

How to exit [detach] a screen session

While in a screen window, use Ctrl + A then Ctrl D. This takes you back to your main terminal.