Difference between revisions of "Setup Bash"

From WebOS Internals
Jump to navigation Jump to search
Line 25: Line 25:
  
 
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.
 
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.
 
+
==Bash profile==
 
'''Add custom aliases/paths/editor etc with /etc/profile.d dir'''
 
'''Add custom aliases/paths/editor etc with /etc/profile.d dir'''
  

Revision as of 19:41, 25 September 2010

Setting up Bash as a Replacment Shell for /bin/sh

Preliminaries

  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.

Before:

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

After:

> 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.

Bash profile

Add custom aliases/paths/editor etc with /etc/profile.d dir

//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'
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

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

Credits

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