Monday, December 13, 2010

The Most Basic Possible Screen Tutorial

Screen is neat. It allows you to start long running processes (like fsck or a big network copy) and then log out.

Also if you're getting into your box over ssh or something, it preserves the login if the connection goes down. I imagine that it survives the death of X and other unfortunate events also.

Screen's neat. But I can never remember how to use it when I need it. This is for me:

Install it:
$ sudo apt-get install screen

Start a terminal.
In this terminal type:
$ screen

There will be a screen full of crap: Press Return to make it go away, and wait a second or so.
Apparently you will be back at a terminal. But it is really a screen session.

Start a long-running task:
$ htop

Detach from your session using C-a d (ie, hold down control, press a, release control, press d)

You are back at your terminal:

Kill it:
$ exit

Now switch to a virtual console with Alt-Ctrl-F1

log in

Reattach to the screen session
$ screen -r

You should have htop running before your eyes.

Detach from your session with C-a d

Switch back to X with Alt-Ctrl-F7

Open a terminal

Reattach to screen with
$ screen -r

Exit from htop with F10 (actually your terminal emulator may catch F10 and do something with it. Getting out of htop is then left as an exercise for the reader.)

You are back at a terminal which is really a screen session

Exit from the screen session with
$ exit

Everything is back to normal.

Here's an ever so slightly less basic tutorial:
http://www.howtoforge.com/linux_screen

Sunday, December 12, 2010

Finding USB disks and external harddrives

$ sudo fdisk -l

will list all disk drives and their partitions, allowing you to find out that your usb disk has attached itself to /dev/sdh today.