Setting up Bash as a Replacment Shell for /bin/sh
- Gain root access.
- Setup the Optware Feed.
- Open the root file system to read/write with rootfs_open. If you haven't yet altered your PATH (see below) use the following:
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:
2. Add your rc file (name doesn't matter as long as it isn't a .file):
3) Add aliases and PATH options. Here is what I have:
alias nano='nano -zwc' alias ls='ls -aF' alias ll='ls -alF' PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin::/opt/bin:/opt/sbin EDITOR='nano' export PATH EDITOR
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
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).