LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Replacing Big Fat Bash with Dash for Scripting

A while a go I looked at Bash replacements for interactive shells. Unfortunately for me, I am just getting too used to having Bash on the command line and can’t get myself used to other shells.

However, interactive shell is one thing, and scripting shell is another. If your scripts are compatible with the original bourne shell, then you should try dash instead of that big fat Bash! This morning I just discovered one of my Debian 5 VPS is not having /bin/sh linked to dash by default, so I “fixed” the problem, and here is the memory consumption result:


$ ps aux | grep /bin/sh
root      7473  0.0  0.1   2416  1156 ?        S    Feb12   0:00 /bin/sh /usr/bin/mysqld_safe


$ ps aux | grep /bin/sh
root     15528  0.0  0.0   1632   520 ?        S    10:03   0:00 /bin/sh /usr/bin/mysqld_safe

Yup. 1/2 MB reclaimed. Just make sure your /bin/sh is linked to dash. If it’s not already the case, then for Debian/Ubuntu based systems

# apt-get install dash
# dpkg-reconfigure dash

You also need to make sure all your scripts are compatible with sh/dash (which they ought to anyway).

Latest posts by LEA (see all)

1 Comment

  1. MiB:

    I know this is almost four years late, but take a look at mksh as well. It’s a Debian Squeeze replacement of pdksh and it includes a statically-linked binary called mksh-static (/bin/mksh-static) that is trimmed down a bit. It can be used both as an interactive and non-interactive shell and takes just ~200 KB memory on my VPS.

    I also set mksh-static instead of bash for my SSH session and that saved me whole 2 megabytes.

    January 27, 2013 @ 6:00 pm | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *