You can use the Linux screen command to operate multiple shells from one terminal window on Linux. Below is the command to install screen on CentOS Linux.
- yum install screen
Using screen is easy. First SSH to your server as you normally would and before running any commands that may take awhile type “screen”. This will start a screen session which will allow you to either run commands in multiple screen windows or detach the screen, close your SSH connection, reconnect another SSH session, and reattach the screen session. Below are some useful screen commands.
To see what screen sessions are running type the below command.
- screen -ls
This will return results as shown below.
- [root@server ~]# screen -ls
- There is a screen on:
- 16446.pts-2.server (Detached)
- 1 Socket in /var/run/screen/S-root.
You can see above that there is one screen session that is detached using PID 16446, on tty pts-2, on server.
Now to attach to the that screen session type the following command. To detach from the session after it is started type “Ctrl-a d”.
- [root@server ~]# screen -r 16446.pts-2.server
Once you detach using “Ctrl-a d” you will see “[detached]” at the bottom of your shell confirming you have detached the screen session. You can also verify by using “screen -ls” to confirm the session shows detached in the listing of screen sessions. The screen manpage is very detailed and can be found here.