Screen command in Linux
— #linux
Use screen command to create a new virtual window from a single SSH session, and run other stuff there. In the example below we’ll be installing screen and then running a Django dev server in a new virtual terminal window.
apt-get install screen
screen
python manage.py runserver
You will see that Django server has started running.
Now press Ctrl+A
and then press the D
key to detach from that screen. It will say:
[detached from ###.pts-0.hostname]
You can now safely logout from your terminal, log back in to your terminal, do other bits of coding in other directories, go for a vacation, do whatever you want.
To return to the screen that you have detached from
screen -r
To kill the django server now, simply press Ctrl+C
like you would’ve done normally.
To terminate this current screen instead of detaching from this screen, use Ctrl+D
.
It will say:
[screen is terminating]
For more information about using screen check out thease articles:
https://www.tecmint.com/screen-command-examples-to-manage-linux-terminals
https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to
https://www.howtoforge.com/linux_screen