This article describes how to use the screen program.
Have you ever been working at the command line over a SSH connection and the connection drops? Alternatively, have you ever wanted to run multiple programs from the command line without opening a separate SSH connection to run each command?
The screen program can handle these scenarios and more. You can use screen to maintain an open terminal session, even if the connection drops. Likewise, you can open multiple text windows and run multiple commands from within a single SSH session.
To start screen, log in to your A2 Hosting account using SSH, and then type the following command:
screen
You can obtain a list of active screen sessions by typing the following command:
screen -ls
You should see output similar to the following text:
There is a screen on: 231102.pts-2.sr10 (Attached) 1 Socket in /home/username/.screen.
This output shows that you currently have one attached screen session. You can type commands and work in the shell as you normally would.
man screen
You may also want to create a customized status bar to make it easier to see which window you are currently using. To do this, create a ~/.screenrc file. For example, to display the server hostname and window name at the bottom of the screen, add the following line to the ~/.screenrc file:
hardstatus alwayslastline "[%H] %w "
By default, some types of accounts (such as shared hosting accounts) may not be able to use the screen program. For screen to work, the bash shell must be enabled on your account. To determine your current shell environment, log in to your account using SSH and type the following command:
echo $SHELL
If your shell is set to jailshell, the screen program will not work. If you want to use screen, open a ticket with the A2 Hosting Guru Crew at https://my.a2hosting.com and request that the bash shell be enabled for your account.
However, even if the bash shell is enabled for your account, you may receive an error similar to the following message when you try to start screen:
Directory '/var/run/screen' must have mode 775.
If you receive this error message, type the following command:
mkdir ~/.screen && chmod 700 ~/.screen
Then add the following line to your ~/.bashrc file:
export SCREENDIR=$HOME/.screen
Log out of SSH, and then log back in. Screen should now work.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.