howto: use screen to keep your ssh sessions running

screen is a program that will allow you to keep multiple terminal sessions running and easily switch between them. It also protects you from your session ending if you get disconnected.

to install screen in ubuntu, open a terminal and type the following:

sudo aptitude install screen

now you can start a new screen session by just typing screen at the command line. You’ll be shown some information about screen. press enter, and you’ll be at a normal prompt.

sudo aptitude install screen

to disconnect from ssh, but leave your session open, do the following:

press ctrl+a and then ctrl+d in immediate succession. you will see the message [detached]

to reconnect to an already running session

screen -r

to reconnect to an existing session, or create a new one if none exists

screen -d -r

to create a new window inside of a running screen session

press ctrl+a and then c in immediate succession. you will see a new prompt.

to switch from one screen window to another

press ctrl+a and then ctrl+a in immediate succession.

to list open screen windows

press ctrl+a and then w in immediate succession

there’s lots of other commands, but those are the ones I use the most.

 

Tagged: ,

Discussion

No comments yet, be the first.

Add a Comment

*