2011-08-09

Command Line Linux on a WebOS phone

(Or how to install Nethack on your phone)

The WebOS (HP/Palm) phones are some of the most interesting phones to me as a technology guy (geek). They, more than iPhone or even Android allow you to have easy, supported (or at least not hindered) near ultimate control over your phone. More particularly, underneath WebOS, is a real Linux system. Once you enable it, there’s even a package management system similar to apt-get.

And while the actual setup of access the Linux command line was relatively simple, there were a few places where steps were harder that they should be. So this is my attempt to write down what I did to get it working.

Note: The Preware documentation is excellent. Kudos to the WebOS Internals team for their efforts. It’s worth the $.99 to get it. And it supports the the WebOS Internals project.

However, to get to a real Linux command line experience on your WebOS phone, you need to go a few steps further than what the Preware documentation talks about.

So I’ll start where that document leaves off. Now, as I’ve only had a WebOS phone for a few days, I may well not know the best way to accomplish this – I’m just going to share what worked for me. Hopefully if there are better ways, someone can respond and I’ll try to update these instructions.

Step 0. Preliminaries:

Follow the instructions in the Preware Homebrew Documentation. (It really is worth the $.99 in the App Catalogue) Once you have downloaded WebOS Quick Install and installed Preware on your phone, go on to the next step.

Step 1. Go to Preware, install "Bourne Again Shell"

Note 1: the best way to find something in Preware is to swipe back until you see the "List of Everything", choose that and then start typing. That will search for the package you want.

Note 2: I’m not sure that it’s necessary to install Bash, it seems like I read that there is a default version of sh installed. However, I had already installed Bash before I realized this, so to maintain the integrity of these instructions, I’m including this. Plus, bash is a better shell for interactive use than sh.

Step 2. Install a terminal app.

To get to the command line, you will need a terminal app of some kind. This is the most annoying part of the instructions currently. This part shouldn’t be as hard as it it.

Unfortunately, the most talked about terminal app "Terminal" apparently no longer works on the current versions of WebOS, and so has been removed from Preware. Xterm is the other terminal that is talked about online. However, I was not able to get it to work when I tried (some library wasn’t found). Also, I don’t know how to invoke xterm from WebOS without having a terminal present. So, there’s a little bit of a chicken and egg problem.

So, that leaves us with 2 choices, Terminus and SDLTerminal. I very much suggest SDLTerminal at this point, but I’m going to go through the process to get both up and running.

Terminus

Terminus is available in Preware. However it may not come up successfully out of the box. (If it looks like just a blank screen, the you will need the below instructions) Also, I haven’t been able to find any list of keybindings for things like ESC, Ctrl, and various symbols necessary for Unix like |, <,>, etc. In addition, it’s font size is tiny to the point of miniscule on the HP Veer’s small screen.

However, here is what you have to do to get it to be minimally viable (unfortunately I don’t know how to get it to be more than that).

  1. Install "Internalz Pro" from Preware.
  2. Open Internalz Pro and go to preferences.
  3. Under the "Text Editor" section change the "Newline format" to "Linux".
  4. Using Internals Pro, navigate to /var/palm/data
  5. Open the file "jailusers"
  6. Find any lines that have "terminus" in them.
  7. Delete every line with "terminus" in it except for the one that ends in "jail_native-palm.conf"
  8. Save the file

Terminus should now come up and display a shell prompt (rather than just blank screen with a cursor). However, as I mentioned before, it’s font size is tiny, and I can’t tell how to create special characters, so its utility for me was minimal.

Therefore I started looking at SDLTerminal …

SDLTerminal

While I vastly prefer the experience of SDLTerminal, installing it is a hassle. Here are the steps it took to get it on the phone.

Note: while SDLTerminal is listed in Preware, I (and others it appears) have had trouble downloading it from there. For me the download just sat there spinning each time I tried to download it.

The solution at this point is to search PreCentral for SDLTerminal. The first thread that comes up is the one you want. You will need to have register with PreCentral if you haven’t already to be able to download the file you need. Registering with PreCentral was it’s own hassle. If I’m able later I’ll try to find a link to the page that actually let me register.

  1. Find the top thread on PreCentral for SDLTerminal
  2. Go to the first post on that thread

Note: You should copy down the keybindings from that post somewhere, as they are necessary for effective command line use on Linux

  1. Download that file to your computer
  2. Unzip that file, there will be a .ipk file inside.
  3. Make sure your phone is in "developer mode" (refer to the Preware Homebrew Documentation mentioned earlier)
  4. Connect your phone back to your computer, choose "just charge".
  5. Open WebOS Quick Install (used earlier to install Preware)
  6. Choose the .ipk file that was in the zip file (I believe you use the "+" button in Quick Install and browse)
  7. Click "Install" in Quick Install

At this point SDLTerminal should be on your phone. You can disconnect your phone from your computer, close Quick Install, and turn off developer mode on your phone if you want to.

SDL Terminal should come up and you should see a usable shell prompt. Try a few Linux commands like pwd or ls.

Now for the rest of the Linux system.

Go back to Preware and install "Optware Advanced Linux Command Line Installer"

This will install a command line package manager similar to apt-get. In this case it is called ipkg-opt on the command line.

Note: you may also need to install "Optware Bootstrap" but I think it may have been installed automatically when I installed the above package.

Run "ipkg-opt list" to get a list of packages available for install.

(You probably want to do "ipkg-opt list | less" since SDLTerminal doesn’t appear to support scrolling at this time.)

At this point you should be able to install anything you want.

For example,

ipkg-opt install nethack

I installed openssh, inetutils, and yes, nethack. Now I can ssh into my web servers to edit config files or restart webservers from my phone if I need to. Although the experience would be a bit constrained, I could even write programs on or from the phone if I wanted to.

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s