CentOS 7.x screen
Home > CentOS > CentOS 7.x > Desktop tools or applications > CentOS 7.x screen
It is useful to run commands in screen so that we can later connect our ssh to machines and continue monitoring the progress. Refer: http://www.linuxcommand.org/lc3_adv_termmux.php for useful terminal multiplexing options such as screen or tmux or byobu.
Install screen
To install screen use:
yum -y install screen
Start new screen session
To start new screen session use:
screen
After this use the screen terminal like any other linux terminal.
To give a meaningful name to session use '-S' such as
screen -S <name>
This name can be later used to identify screen.
You can start multiple virtual screens within a screen. To start a new virtual screen use:
- 'Ctrl-A c'
shortcut. That is press Ctrl-A and leave both Ctrl and A, then press 'C'.
If you do use virtual screens then following additional shortcuts would help:
- 'Ctrl-A p' - Go to previous virtual screen
- 'Ctrl-A n' - Go to next virtual screen
- 'Ctrl-A A' - Set title for current screen
- 'Ctrl-A "' - List all screens and select them by title
- 'Ctrl-A [0-9]' - Go to particular virtual-screen
Stop current screen session
To stop current screen session simply exit from bash screen
exit
To list running screens
To list running screens use:
screen -ls
This will give screen session IDs of all running screen sessions
To disconnect current screen from terminal
To disconnect screen while you are connected to it use shortcut
- 'Ctrl-A D'
That is press Ctrl-A and leave both Ctrl and A, then press 'D'.
To disconnect running screen from terminal wherever it is running use:
screen -d <screen-session-ID>
To connect to a running screen
To connect to a running screen use below. If required below command will detach anyone connected to mentioned screen and would connect the person executing the command to the screen.
screen -r -d <screen-id>
To create or connect to screen with name
To connect to an existing screen or create one if does not exists with name use:
screen -d -RR <name>
This way if screen with <name> exists, you will get connected to it. If screen does not exists then it would be created.
Read 'man screen' for more information
Home > CentOS > CentOS 7.x > Desktop tools or applications > CentOS 7.x screen