A practical look at the Screen terminal multiplexer
|
Scripting
Screen can also be controlled by scripts, which means that commands can be sent to separate sessions at Screen startup or later at the command level. For example, using
$ screen -X stuff "ls -lh\r
would run the ls -lh command in window 0 of the session. Screen needs you to specify the final carriage return (\r ) to execute the command. If you want to control another window, use the -p option followed by the name or number of the window.
You can also pass Screen commands to open sessions. The command
$ screen -p 2 -X kill
would shut window 2 of the Screen session, or
$ screen -X multiuser on
would make a session multiuser. With multiple Screen sessions running, you can specify which session you want to send a command to with the -S <pid> parameter.
Conclusion
For admins who use the command line often, using Screen can make work easier in many ways. Of course, this applies to other terminal multiplexers as well, but Screen, unlike Tmux, still basically uses the key bindings that were once common used in many serial console programs.
Screen has a huge range of functions, although some are rarely used in practice. In any case, a glance at the documentation helps you see what's available and what might come in handy later on.
Installation
GNU Screen is usually quick to install. On Debian and derivatives such as Ubuntu or Linux Mint, you can install the multiplexer with
$ sudo apt-get install screen
Users of Arch Linux can do this with
# pacman -S screen
To install the newest version [3], however, you can't avoid using the classic ./configure; make; sudo make install trio.
Infos
- GNU Screen: http://www.gnu.org/software/screen/
- Announcement of Screen 4.2: https://lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html
- Download: http://download.savannah.gnu.org/releases/screen/
« Previous 1 2 3 Next »
Buy this article as PDF
Pages: 4
(incl. VAT)