Setup Bash

From WebOS Internals
Revision as of 19:31, 25 September 2010 by Papa4narchia (talk | contribs) (Setting up bash as a replacment shell for /bin/sh)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Setting up bash as a replacment shell for /bin/sh

The Palm webOS devices like Pre and Pixi come with the Bourne shell as the default stock shell. The Bourne-Again Shell, or bash, is available via optware. This is how you can set it up.


  1. Gain root access.
  2. Setup the Optware Feed.
  3. Open the root file system to read/write with rootfs_open. If you haven't yet altered your PATH (see below) use the following:
/usr/sbin/rootfs_open -w

Install bash

ipkg-opt install bash

Super Important: Before you switch your login shell in /etc/passwd, you MUST create /etc/shells and add /opt/bin/bash and /bin/sh to it. If you do not, you will lock yourself out of the Pre on anything but novacom term if you switch your default shell.

echo -e "# /etc/shells: valid login shells\n/opt/bin/bash\n/bin/sh" >/etc/shells

now you can vi/nano whatever /etc/passwd and replace your unprivileged user shell with /opt/bin/bash.


> youruser:yourpasswordhash:1001:1001:Linux User,,,:/var/home/youruser:/bin/sh


> youruser:yourpasswordhash:1001:1001:Linux User,,,:/var/home/youruser:/opt/bin/bash

Try to SSH in with that user and be sure you can access the machine. Change root as well if you desire. Since you will probably 'sudo su' to root to perform larger tasks, you will want to stay in consistent shell.

Setup your bash profile

When a user logs in, the shell provides a certain environment for the programs running in your users context. This is achieved by setting environment variables in scripts, stored in multiple locations. That includes /etc/profile (for all users) and all the files in the /etc/profile.d directory. (Other linux distributions often add ~/.bash_profile and ~/.bashrc as well to the home directories of users.)

/etc/profile.d/ is a good place to put your application specific setups and thereby setting up custom aliases, paths, editors etc. Additionally, we can append aliases and logout scripts into this /etc/profile.d folder.

1. Create the directory:

mkdir /etc/profile.d

2. Add your rc file (name doesn't matter as long as it isn't a .file):

vi/nano/etc /etc/profile.d/profile.custom

3) Add aliases and PATH options. Here is what I have:

alias nano='nano -zwc'
alias ls='ls -aF'
alias ll='ls -alF'

nano -zwc will allow nano to suspend with ctl-z and not wordwrap by default as well as show you the line numbers that your cursor is on (avoid having to hit ctrl-c looking for line numbers).

These are my preferred ls cmds (yours may vary):

PATH is adding the /opt/bin and /opt/sbin paths so your optware binaries work easily. This is a complete overwrite of the PATH set by default and applies to your unprivileged user as well as root. Keep that in mind if you try to run stuff out of /sbin dirs...

EDITOR is setting your editor of choice for things like crontab edits or subversion if you were using that on the Pre. If you are happy with vi, you can skip the EDITOR set. If you're reading this guide, you probably want nano...

nano is easily installed with

ipkg-opt install nano

Okay. You are done...remount the root file system as readonly:

mount -o remount,ro /

There's no need to reboot, but if you logout and log back in you can make sure you are in bash... Type some gibberish:

> root@castle:/etc# asdf
> bash: asdf: command not found

Mmm, bashalicious...

NOTE The 2nd command from the top was adding /bin/bash to /etc/shells, NOT /bin/sh. I fixed it. Also, I wasn't able to get /etc/profile.d/profile.custom to work, so I used ~/.bashrc instead. -hopspitfire


Submitted by retry. Tested to work by hopspitfire (see NOTE above).