Screen SSH Technology Ubuntu

SSH and Screen – Useful Tips

SSH
Screen is very useful in running processes despite losing connection to remote server connected with SSH. The detached process could be attached to the terminal and we could continue the work at later stage. This will show you how to use screen utility.

On Debian and Ubuntu, you just run the following command to install screen.

apt-get install screen


To Start a new screen session just type the following command in ssh terminal

screen

To Start a new screen session with user defined session name
 
screen -S sessionname
 

More commands for screen

Ctrl a c – Creates a new screen session so that you can use more than one screen session at once
Ctrl a n – Switches to the next screen session (if you use more than one)
Ctrl a p – Switches to the previous screen session (if you use more than one)
Ctrl a d – Detaches a screen session (without killing the processes in it – they continue)

Use the following command to close screen session once all the tasks done,

exit

To browse two or more screens,

Ctrl a n / Ctrl a p
 
To view all the detached screen sessions, type the following on the normal SSH terminal,
 
screen -ls
 
Assume we have two screen Sessions as below, which could be viewed from screen -ls command,
 
There are screens on:
        2477.pts-0.server1      (Detached)
        2522.pts-0.server1      (Detached)
2 Sockets in /var/run/screen/S-root.
 
To reconnect to one of the screen session,
 
screen -r 2477.pts-0.server1
 
To close the session,
 
exit
 
Spread the love
Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
S Ravibalan
13 years ago

@Mujah, Answers for your question updated 😉

S Ravibalan
13 years ago

@Anonymous (aka Mujah)
Ill do some research and update later… lol 😉

Anonymous
Anonymous
13 years ago

Good one ..
How do we start screen with a name ?
And can we have threading option when starting a screen ?