Using the Linux Screen Command
I use Digital Ocean for hosting many different Linux servers that I have:
longeststreak.net, this website, a private Discourse forum, a
private minecraft server, and one I use for programming (the one I’m using right
now to write this post). The point I’m getting at is that I end up SSH’ing into
these boxes a lot and one tool that I use every time is the screen
command.
Screen allows you to connect back to the exact same terminal you were on in case
your connection got lost while writing in vim. Another example is so that you
can start a process like minecraft and not have to use the &
symbol for it to
run in the background.
Screen also allows you to create windows so that if you need another shell on the same box you don’t have to ssh in again.
Here are the screen commands that I use most often:
screen
- starts a new screen sessionctrl-a d
- detaches from screenscreen -ls
- shows a list of screen sessionsscreen -D
- detach an active screen (necessary if you connection is lost and you are SSH’ing back into the box)screen -r
- re-attach to screen sessionctrl-a c
- create a new screen windowctrl-a n
- switch between screen windows
The point of this post is not to give an exaustive tutorial on screen
, but to
make you aware that it exists and give you a few commands to help you get
started. If you aren’t using screen
yet I hope you can start.