Archive for the 'gnu screen' Category

Playing in Console

April 22, 2008

I’m pretty happy I can switch back and forth between console and X now that I have my tty issues resolved with Vector. I decided to find tools to take console shots. I settled on fbdump aliased to pipe the dump through pnmtopng and output a time-stamped png.

This is a scaled shot of my gnu screen session with htop in the foreground.

I’ve set up every .screenrc I use with hostname so I know which computer I’m working on. Comes in handy and helps me keep things straight if I have screen sessions running on multiple computers — home server, work computer, work server, etc. — and shelled in on different ttys. Click on the image below for the 640xn full size version of the caption:

Notice how gentle the demands of console apps are in comparison to GTK1 and GTK2 apps in X (click for full scale):

By contrast, I’m running X and Firefox GTK1 now (one tab open to edit this post). I opened one instance of aterm to run htop. It’s showing 71 MB memory in use.

For what it’s worth, the memory use when I open htop after I boot up and wifi starts is 17 MB. I could probably get that down another MB or two by not starting certain modules I don’t need to start.

Here’s the caption line from my .screenrc:

caption always “%?%F%{-b yk}%:%{-b bb}%?%H %{-b rk}%?%C %{-b wk}| %?%F%{-b bk}%? %L=%-Lw%45>%{-b ck}%n%f* %t%{-}%+Lw%-0<”

Since seeing what Vector Light is/isn’t, I’m going to proceed with the lower resource slackbuild I’ve mentioned the last few days. I’ll post some more ideas in the coming days about the levels of build I think are possible (minimal without X, minimal with X and mix of console and GTK1 apps, and low resource GTK2).

Edit: Here’s a shot showing htop at six minutes uptime with only htop running.

Edited again: It’s not like an obsession or anything, but I got it down to 15 MB:

Note that htop doesn’t count cache (so free -mt actually reports that I’m using 80-something MB). It’s also relevant that to do this I blacklisted all the sound modules that normally would load; I don’t do audio on the laptop — my mp3 player battery lasts longer between charges and the player sounds a lot better.

How I Roll: sshfs

March 24, 2008

I’m not exactly a road warrior, but most of what I do is in the field. I’ve written in various forums that there are a few applications and utilities essential to me and “how I roll.” One of them is GNU screen. Another is SSH. These two allow me to work from the same session anywhere without ever stopping.

I’m also a huge fan of sshfs. This is a FUSE filesystem that allows a user to mount a remote home partition via SSH as though it were local.

Here’s a little tip if you’re working on a laptop in a situation where you have limited space on its hard drive, or if you’re in an area where there’s significant risk of losing your data through computer theft or some kind of disaster. It’s also cheaper than buying a new laptop hard drive.

Let me give an example. Let’s say you’re on your laptop at the university. There’s significant risk of theft of laptops and everything else. You need to work on your project but you want to insure you don’t lose all your effort in case your laptop “disappears,” if it gets dropped, whatever. You can lose an entire semester’s (or longer) work if something bad like that happens.

WIth sshfs, you can keep your work on your desktop (or server) computer at home. It doesn’t end up on your laptop’s hard drive, but you still have the easy and fast access as though it were because it uses the Unix idea of “everything as a file” in joining remote to local.

You would only need to run ssh on the computer at home so that you can access it remotely (and as securely or insecurely as you desire). On the laptop, you would run the fuse module and then enter the command:
% sshfs username@path.to.desktop.or.server: laptop.mountpoint/

So if your account name at home is “lucky” and you want to set a mount point (directory) on the laptop for “remote” it would look something like this:
% sshfs lucky@my.home.network: remote/

You’re asked to enter the password for user lucky and then that mounts the entire /home/lucky directory on the other computer to ~/remote on the laptop. Once you do that, you can transfer files back and forth as though it were all local — the same as any other files or filesystems mounted on your computer.

If you have a similar/compatible set of applications on both computers, you can also just get with it and use your remotely stored data files with your local applications. If you’re using Open Office’s calc or Gnumeric for your spreadsheets, you would just open whichever files from the remote computer on the local one. Then when you save, you’re saving remotely.

This minimizes the need to sync files between laptop, desktop, and/or server or keep up with multiple versions of the same data because you can use the same version universally. You can get by with less space on your remote/laptop hard drive if you have large files to work on. Just use your larger (cheaper) hard drive on your desktop/server for all your storage.

When you’re finished and want to unmount the remote system and terminate SSH, you enter:
% fusermount -u ~/remote/

Since it uses SSH, it’s more secure than a lot of other options including keeping data on tiny USB devices that can disappear even easier than laptops. And while there can be risk of theft of your desktop computer while you’re away, that risk is much lower if you use a bulky old (cheap) computer for such purposes. The more stuff you put in it to weigh it down (six combined floppy and optical drive slots don’t have to be filled with working — or even connected — drives), the less likely a thief will be interested in carrying it. Instead of adding another working computer (or broken floppy and Zip drives) to your local landfill, why not put it to good use?

It doesn’t need to be bleeding edge, you just need to be able to shell into it to access your safe data and have enough storage to make it worthwhile. It also doesn’t have to be big and heavy as described above — you could carry a “craptop” on campus and leave your good laptop in the safety of your home. Whatever you use can serve other duties as well if you put your mind to it.

And you can get by without ever touching your laptop hard drive (or needing one). Some Linux live CDs, including Damn Small Linux, come with FUSE and sshfs. Since DSL contains extensions like Open Office, Abiword, Gnumeric, etc., it would be quite easy to work remotely like this.

Both FUSE and sshfs are available with nearly all Linux distributions or should easily be added if not, as well as for FreeBSD and NetBSD (possibly other smaller ones, but not to my knowledge in OpenBSD). More FUSE fun soon.

Ratpoison, Screen, SSH

March 10, 2008

I’ve spent a lot of time this past week (and weekend) using the same screen session on my primary computer remotely from my laptop. This has allowed me to do things like compile without burning up my laptop (it gets VERY hot compiling), run the same session of naim, etc., and check back in as I can. No down time between travel, commuting, work, play, etc. I pick up everything right where it is no matter where I go.

I’d installed ratpoison on the laptop when I first installed Vector Linux. At that time, I was willing to give XFce a fair shot against window managers with lower system requirements (not fluxbox, more like jwm). I liked it, but it wasn’t as lean as I thought it should be. Then I installed KDE for a bit. I really like having a fully integrated system, but my laptop isn’t really up to running that.

So I’ve removed both XFce and KDE. I’ve been using JWM with a lot of my anti-WIMP mods from Damn Small Linux as my primary window manager. I’ve been using ratpoison more often again lately.

Not just on my laptop — I went ahead and installed it on desktop, too. I installed ratpoison on this computer because I noticed my USB mouse kept locking up and dmesg informs me that Linux can’t enable port 2 and maybe the USB cable is bad. Yep. After 10 years of abuse, it probably is. Once again, the mouse is unplugged and I’ve set things up so I can live without it (but I did plug it in so I can scroll while I edit this online).

I removed 9menu, which installs with ratpoison via Debian testing, and installed ratmenu as well as xbindkeys. I would’ve compiled xbindkeys on my own if I’d noticed the Debian version requires libguile-ltdl-1, libqthreads-12, and guile-1.6-libs — 2.654 MB(!!!). Ouch. I might go ahead and do that but I have this thing down to under 1.5 GB of disk use now.

What’s not to love about that?! It’s just vim with my ratmenu running in screen. I have a dark-ish grey (grey33) background and default grey text (good old size 10 fixed font!) in aterm. That’s the same screen session that’s been running for over a week, detached and re-attached probably 200 times locally and remotely.

I’m not anti-WIMP. I know there are people who carp on icons and menus and say they get in the way. Do they? Or are they really any different from shell wrappers and aliases? I don’t think they are. I think of that when I edit menus and aliases and write wrapper scripts.

Let me give an example. You probably can’t read the second to the last line clearly in the menu: it says “screen-scaled.” I wanted the ability to produce a scaled screenshot on the fly. So I appended an ImageMagick import line with convert to produce a 400×300 shot suitable for posting on blogs. I write the command(s) once either way whether it’s a wrapper script or a menu item or an alias. Let’s say I alias it as “scaledshot.” When I type sc-TAB, I’d get 28 possibilities for autocompletion. Add the l-TAB, four possibilities. So I’m already at five keystrokes and in need of another e-TAB — seven strokes. I know I can limit that with zsh by TABbing until I find the right one. That still would put me at six anyway.

How much of a barrier is my menu? Ctrl-z-y (I rebound my escape to z) give me a menu. Two up arrows take me backward to that line. Return. Done. Five strokes. Too many? I can bind that to shift-print (print is taken up for the full shot) or something else. If I were so inclined, I could bind it to an icon in another window manager and with one short motion and one click I’d have my stupid 400×300 screenshot to show the world how boring my computers are most of the time.

Anyway, I’m not getting too carried away with filling in the menu. Most stuff will be console anyway and run in screen. The point is, there are plenty of ways to do things. Right now, this is mine. At least til I go buy a new mouse.