Tuesday, November 27, 2012

Screen | Linux Command

When you run commands and programs in a command prompt on Linux, the programs or commands only run while the command prompt session is open but as soon as the command prompt session is terminated for whatever reason, the commands or programs running within the command prompt session will also get terminated.
I use wget to download files from the internet using my putty console all the time. Imagine downloading a 500mb file and then suddenly putty crashes causing my session to terminate along with it. There goes my 500mb file download!! I so wished I had known about the “Screen” program then.
The screen program is a magnificent utility. Screen basically starts a session within the the session that you logged in with. So, if your putty session suddenly crashed don’t worry, the screen session would still be running in the background. Log in again to the server using putty and you should be able to retrieve the screen session you initiated earlier.
# screen
This starts a screen session.
# Ctrl + A followed by D
This will detach your screen session and return you to the original session you logged in with. Your screen session will now be running in the background.
# screen -r
This command will resume your previous screen session.
# Ctrl + A followed by Ctrl + (back slash)
# exit
You could run either command above to end a screen session.
# Ctrl + A followed by “
This command will list all the available screen sessions running if there are.
Usefull Links:
O’REILLY Linux Command Directory

Inside Open Source