482 CHAPTER 34 ACCESSING COMPUTERS REMOTELY her network connections using something similar to the netstat command, then she would see another computer attached via ssh. To end an ssh session, simply type exit. This will then return you to the command prompt on your own machine. Tip There s a version of the ssh client that runs on a variety of non-Linux operating systems, making it possible to log in to your Ubuntu machine from a Windows computer. The program is called PuTTY and can be downloaded from www.chiark.greenend.org.uk/~sgtatham/putty/. MANAGING REMOTE SESSIONS Whenever you open any kind of shell to enter commands and run programs, you might have noticed that any commands you start running last only as long as the shell window is open. When the shell window is closed, any task running within it ends, too. This is because the shell is seen as the owner of the process, and when the owner dies, any processes it started also die. When using ssh to start a remote shell session, this also applies. Whenever you log out, any tasks you were running are ended. This can be annoying if, for example, you ve started a lengthy download on the remote machine. Effectively, you must remain logged in via ssh until the download has finished. To get around this, you can use the handy screen program. This isn t specifically designed to be an aid to remote logins, but there s no reason why it cannot be used in such a situation. The screen program effectively starts shell sessions that stick around, even if the shell window is closed or the ssh connection is ended or lost. After logging in to the remote computer via ssh, you can start a screen session by simply typing the program name at the prompt: screen After pressing the spacebar as prompted to start the program, there won t be any indication that you re running a screen session. There s no taskbar at the bottom of the terminal window, for example. screen works completely in the background. Let s consider what happens when you detach and then reattach to a screen session. To detach from the screen session, press Ctrl+A and then Ctrl+D. You ll then be returned to the standard shell and, in fact, you could now disconnect from your ssh session as usual. However, the screen session will still be running in the background on the remote computer. To prove this, you could log back in, and then type this: screen -r This will resume your screen session, and you should be able to pick up quite literally where you left off; any output from previous commands will be displayed. To quit a screen session, you can either type exit from within it or press Ctrl+A, and then Ctrl+ (backslash). The screen program is very powerful. To learn more about it, read its man page. To see a list of its keyboard commands, press Ctrl+A, and then type a question mark (?) while screen is running.