This guide is about a utility that is called Screen. It’s in the ports collection of FreeBSD and it lets you setup a virtual Shell enviroment which you can connect and reconnect to even when you where totally disconnected or turned off the client PC.
I use it a lot for compiling and for programs I cannot fork to the background on remote systems.
- Up to date ports collection.
- root rights or sudo rights.
First we are going to install the screen utility.
# /usr/ports/sysutils/screen/make install distclean
When the compiling is done we can start the program with the following statement
# screen -mS
Now you are automatically connected to the inside of the screen program. We can start any program just like a normal shell.
to leave the screen press the following keys “CTRL+A” let go of the keys and then press the “d” key.
Now you see the words screen detached, you are back in your own console space. You can disconnect the server or continue working on something else.
When you want to check/close the screen you can do the following command.
# screen -ls
Now you can see a list of active virtual consoles that are running. With the following command you can re-attach a running screen
# screen -r
You can totally let the screen exit by pressing the “q” key.
You can probably imagine tons of scenarios where this utility can come in handy so I don’t think I need to explain more about this, just try it and see how it works.