Screen is a handy terminal application which runs on top of Linux terminal itself. This means allows you to create sessions with in a terminal and each session are self contained.
A feature that I use of screen is the detachable feature. Each screen session is attachable. Once it has been detached you return to your original shell and can exit / logout but the screen session would still be running as long as the computer itself is still running. You can log back on later and reattach to the screen session and continue from where you left of. This gives you the ability to run long intensive tasks, detach the session and come back to it later when it has finished.
In Ubuntu you have to install screen first:
sudo apt-get install screen
When GNU screen is started it loads a fresh terminal. To do screen commands it is usually these keyboard key combinations:
ctrl+a
Followed by a key or typing a command.
To start screen:
screen
It is always advisable to name your sessions with a name. This can be done with the -t argument. For example
screen -t formatUSB
The screen session can also be named within the session itself:
ctrl+a
:sessionname formatUSB
To “detach” a screen and come back to it later use:
ctrl+a d
This will through you back to your original terminal before you started screen. What ever you left running in Screen is still running in the background.
To get back into your Screen terminal use the command screen -r
If you only have 1 screen running it will attach that Screen. However if you have multiple Screens you can list the screens running using the argument -ls e.g screen -ls
This is where naming your screen sessions comes in handy otherwise they are just a process number and a few other Linux environment variable thrown into the name. Using the normal attach arugment but parse it the name to reattach to a specific screen e.g screen -r formatUSB
Here’s a cool way of splitting the terminal in Linux using Screen. It allows you to have a two terminals open at the same time and displayed at the same time with the ability to tab between them. It is possible to split them up multiple times but I have found two was enough.
For a horizontal split do the following keyboard shortcuts:
ctrl+a shift+s
Split the screem
ctrl+a tab
Tab to the lower screen
ctrl+a c
Create a new screen
Use ctrl+a tab to switch between the upper and lower screens. Each screen can be further split by doing the same combinations again. The key combination seems odd because I associate ctrl+a as select all.
Vertical & horizontal split for man screen Article from CodeSnippets