sdjf > ps

The ps Command

The BusyBox versions of ps that are the default ps on many popular Zaurus ROMs give very limited information. That is fine if you are not a power user, but if you want to have more complete information available when debugging networking and other kinds of problems, or to use most of my networking scripts, you must have a more fully-featured ps.

Sharp included a fully-featured ps on the original ROMs, so Sharp ROM users probably already have access to a fully-featured ps. To check your Zaurus's version of ps, enter:

bash-2.05# which ps | xargs ls -l

If your output looks like the following, you are okay.

bash-2.05# which ps | xargs ls -l
-rwxrwxr-x 1 root root 89312 May 22 2005 /bin/ps

But if your output looks like the following, you may want to install a better ps.

bash-2.05# which ps | xargs ls -l
lrwxrwxrwx 1 root root 7 Dec 12 2005 /bin/ps -> BusyBox

To see what options you have available, enter "ps --help". The BusyBox's I have seen for Zaurii yield:

bash-2.05# ps --help
BusyBox v0.60.3 (2002.04.27-20:48+0000) multi-call binary

Usage: ps

Report process status

This version of ps accepts no options.

To see what options you are missing out on, look at a good man page for ps or a good tutorial.

If you want to install a better ps, I have put copies of ps from various Sharp ROMs here at esmartdesign. Note the binaries for ROMs 2.38 and 1.12 are identical.

From sl5500 (ROM 2.38) and sl6000 (ROM 1.12):
   md5sum 602103a27e13b84221a56532d27f8ecb
   md5sum c3ea81ed3957d42b288012cb1cca8705
From C3100 (ROM 1.01):
   md5sum 6e066679c2eb88e6ec15536cecc16365

I also unpacked the gzipped version of ps from ROM 1.01, and when I ran an md5sum on it, got the same results as from the sl5500 version, so I am concluding that Sharp used the same binary for ps on all it's models. So, if you want a version that does not require unpacking, use the first of the three links above. The differing md5sums of the gzipped files probably is due to their file names or dates.

Also, my friend with a C1000 running pdaXii13 was able to successfully install and run it, so I think it should be compatible for most Zaurii.

To install your new ps, first copy the symlink for your current version of ps to a safe place, so you can restore it if the binary you install does not work. Then, of course, make a system backup so you can restore things if the version you install manages to muck up or break things. I hope it will not, but make that backup to be on the safe side because I will not be able to fix things in the unlikely event that something serious goes wrong.

Then put the ps binary in the location your ps link to BusyBox existed. On my sl5500 ROM 2.38, that would be in /home/QtPalmtop/bin/ps.

Read up on it in the resources I have posted in my Newbie Resources page. And then have fun with ps!

A fully-featured ps enables the user to specify which of dozens of variables he or she wishes to see, and to customize the output format, or use a default format. Here are just a few of the nifty things you can do with a fully-featured ps.

For example, if you use the "-e" option, you can see which tty and how much time has been used by all processes on the system:

bash-2.05# ps -e
  PID TTY          TIME CMD
    1 ?        00:00:02 init
    2 ?        00:00:00 keventd
    3 ?        00:00:00 swapper
    4 ?        00:00:00 swapper
    5 ?        00:00:00 swapper
    6 ?        5-20:10:29 kapm-idled
    7 ?        00:00:36 kswapd
    8 ?        00:00:00 kreclaimd
    9 ?        00:00:17 bdflush
   10 ?        00:00:10 kupdated
   11 ?        00:00:00 swapper
   12 ?        00:02:02 mtdblockd
  120 ?        00:00:00 sdmgr
  159 ?        00:00:02 cardmgr
  191 ?        00:00:00 inetd
  206 ?        00:00:00 klogd
  224 ?        00:00:14 atd
  255 ?        00:04:35 shsync
  271 ?        00:00:00 launch
  272 ?        00:00:00
  275 ?        01:01:11 qpe
12583 ttyS3    00:00:00 pppd
15149 ?        00:00:05 embeddedkonsole
15150 ttya0    00:00:00 bash
15215 ttya0    00:00:00 ps

Using a fully-featured ps can also make any scripts you write more efficient. Instead of using "grep", "sed", and "cut" to get needed information or fetch information to put in a variable, you can ask ps to simply output the information you need without any extraneous information to be processed.

For example, if I want to create a list of basic information about all chat and pppd processes, and save the information in a file called "nprocesses" as well as outputting it to the console, in BusyBox I would have to do the following:

ps | sed -e '/sed/d; /chat/b; /pppd/b' -e d | tee nprocesses

With a fully-featured ps, I can achieve the same thing with the following on my system, which always uses ttyS3 for chat and pppd:

ps -t ttyS3 --noheader | tee nprocesses

As another example, if I want to check the process status of a pppd job, in BusyBox, I would have to do the following, calling grep, cut, and head in addition to ps, to get the status of the current pppd process:

ps |grep pppd | cut -b 23 | head -n1

And I can accomplish the same thing with fully-featured ps with the following more efficient code, which only calls ps:

ps -C pppd --noheader -o stat=

If you want to sometimes use the BusyBox version of ps, which will remain in ROM, then locate your busybox with the following:

bash-2.05# which busybox | xargs ls -l
-rwxrwxr-x 1 root root 246852 Jan 30 13:26 /bin/busybox

And then make a symlink to it as follows:

ln -s /bin/busybox /usr/sbin/bb

And then check your symlink:

bash-2.05# which bb | xargs ls -l
lrwxrwxrwx 1 root root 26 Sep 3 2006 /usr/sbin/bb -> /bin/busybox

And then call the busybox version of ps as follows:

bash-2.05# bb ps
PID Uid VmSize Stat Command
1 root 1296 S init
2 root S [keventd]
3 root D [swapper]
4 root D [swapper]
5 root S [swapper]
6 root S [kapm-idled]
7 root S [kswapd]
8 root S [kreclaimd]
9 root S [bdflush]
10 root S [kupdated]
11 root D [swapper]
12 root S [mtdblockd]
120 root 1264 S /sbin/sdmgr
159 root 1428 S /sbin/cardmgr
191 root 1552 S /usr/sbin/inetd
206 root 1288 S klogd -x
224 root 1272 S /home/QtPalmtop/bin/atd /var/spool/at
255 root 1252 S /sbin/shsync
271 root 1292 S /sbin/launch
272 root 1380 S /bin/sh ./
275 root 15240 S qpe
31879 root 7572 R embeddedkonsole -qcop /tmp/qcop-msg-embeddedkonsole
31880 root 2592 S /bin/bash
31997 root 2156 R ps

As you see above, there it is, you still have access to your old familiar ps output if you want, but also now have access to a more powerful version as well.

Revised October 9, 2011