Screen allows you to run scripts or commands in their own virtual window within the terminal, essentially allowing you to have a terminal multi-tasking environment where you can switch between your windows or another users at will. This howto will give you the basics of screen plus some other useful features that may help you in your daily administration tasks. This howto is intended to get you up and running with basic screen functionality within just a few minutes. Please read the manpage for a far more in-depth description of features and options.
These are requirements for successfully completing this document.
- Root or appropriate sudo access to the system.
Doing the Work
Basic description of what will be done and what is expected.
- Install screen if it’s not already installed.
- Setup screen for multi-user mode.
yum install screen
Multi-user mode is helpful for sharing a terminal and showing something in real-time because multi-user mode allows 1 or more people observe another performing commands or other system maintenance, or it could allow more than one user access to the status of scripts or custom commands running in separate screens.
setuid the screen binary.
chmod u+s /usr/bin/screen
Edit /etc/screenrc and add this at the top:
###End Multi-user Mode###
Useful screen commands
- List a particular users screen sessions.
- List your own active screen sessions.
- Re-attach to a specific users screen and session.
- Start a screen session and give it a unique name.
- Detach from a running screen session leaving it running in the background.
- Re-attach to a specific screen you’ve named.
- Power detach a screen that you are logged into from another location.
screen -list username/ (the forward slash is important)
screen -x username/shared-session
screen -S unique_name
Hit the key combination:
Control + A/a + D/d (not case sensitive)
screen -R unique_name
This is helpful if you’ve been accidentally disconnected from ssh while in a remote screen session and it’s still attached.
screen -D unique_name
Troubleshooting & Testing
- Read the manpage:
- Can’t find screen or it can’t be found via Yum?
Make sure you’re running authentic Centos and not using a 3rd party VPS, Cpanel, or other shared hosting discount server.
the output of this command should tell you what you have:
uname -a; lsb_release -a; yum repolist all
Should produce output similar to this:
Linux host.example.org 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.4 (Final)
Loaded plugins: fastestmirror, merge-conf, priorities, protect-packages, protectbase, security
repo id repo name status
addons CentOS-5 - Addons enabled: 0
base CentOS-5 - Base enabled: 2,535
c5-media CentOS-5 - Media disabled
c5-testing CentOS-5 - Testing disabled
centosplus CentOS-5 - Plus disabled
contrib CentOS-5 - Contrib disabled
epel Extra Packages for Enterprise Linux 5 - i386 enabled: 3,696
epel-debuginfo Extra Packages for Enterprise Linux 5 - i386 - Debug disabled
epel-source Extra Packages for Enterprise Linux 5 - i386 - Source disabled
epel-testing Extra Packages for Enterprise Linux 5 - Testing - i386 disabled
epel-testing-debuginfo Extra Packages for Enterprise Linux 5 - Testing - i386 - Debug disabled
epel-testing-source Extra Packages for Enterprise Linux 5 - Testing - i386 - Source disabled
extras CentOS-5 - Extras enabled: 324
rpmforge Red Hat Enterprise 5 - RPMforge.net - dag disabled
updates CentOS-5 - Updates enabled: 0
We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centos on irc.freenode.net