A technical note to myself: One way of doing multiple things simultanenously on a server can be by setting up multiple connections via SSH, that’s how I used to do things before. An alternative is to use a single connection and use the command screen
on the remote server. Another good reason to use screen is if you have a long running process that you don’t want to break just because your SSH connection flips on and off with your computer going in and out of stand-by.
This is for absolute beginners. If you don’t know about screen
, this is for you. If you are already familiar with screen
, I probably won’t be able to educate you :o
GNU Screen is a kind of window managment system for the terminal (you’re ought to say terminal multiplexer) and has several advantages over using multiple SSH connections. Most importantly: the processes keep running when SSH disconnects (although you shouldn’t think of it as a replacement for background processes (check init.d for these (for Debian based systems that is)).
I’m assuming you know how to connect to a remote server, and you have already installed, or are able to install screen (e.g. sudo apt-get install screen
). So assuming screen
is installed, to list the currently open screens enter:
screen -ls
Probably you won’t see any screens, and it will say something like ‘no sockets found’.
You initiate a new screen by simply calling screen without parameters (although you may want to use some additional paramters to give them names that you’ll be able to remember).
screen
You’ll see some licensing info and where to go for bugs. Hit space.
Now you’ll see a the prompt, as if nothing really happened. But really, something has. You’ll know that you’re attached to a screen when you enter the screen -ls
command again.
Start whatever you want, and you’ll able to keep it running while doing something else after ‘detaching’ the screen by pressing Ctrl+A followed by the letter d (of detach).
Your now able to set up another screen by typing screen
again and you’ve started another screen session and in case you want to attach again:
screen -x
Well, I’ve just covered the very basics, but see: http://aperiodic.net/screen/quick_reference for a comprehensive quick reference for all the commands (were C-a == Ctrl+A), and learn e.g. about split screens (Ctrl+A, |; Ctrl+A, Tab; Ctrl+A, C) and more. Happy learning!
Enjoyed this? Follow me on Mastodon or add the RSS, euh ATOM feed to your feed reader.
Dit artikel van murblog van Maarten Brouwers (murb) is in licentie gegeven volgens een Creative Commons Naamsvermelding 3.0 Nederland licentie .