What's new

[SOLVED] Change default shell from sh to bash (378.56_2)

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

A couple of checks for you:
- Try this to check for your active shell:
Code:
echo $0
- Did you install Entware and install bash?
If not use this code, as bash completion is no longer available:
Code:
opkg update && opkg upgrade
opkg install bash
- Did you check that your /tmp/etc/profile has these entries. If the are present all is OK.
Code:
[ -f /opt/etc/profile ] && . /opt/etc/profile
[ -f /jffs/configs/profile.add ] && . /jffs/configs/profile.add
 
A couple of checks for you:
- Try this to check for your active shell:
Code:
echo $0
- Did you install Entware and install bash?
If not use this code, as bash completion is no longer available:
Code:
opkg update && opkg upgrade
opkg install bash
- Did you check that your /tmp/etc/profile has these entries. If the are present all is OK.
Code:
[ -f /opt/etc/profile ] && . /opt/etc/profile
[ -f /jffs/configs/profile.add ] && . /jffs/configs/profile.add

Hi thelonelycoder, thanks for your input.

RT-AC3200:~# echo $0
/opt/bin/bash

RT-AC3200:~# echo $SHELL
/bin/sh

For the first command, I got the /opt/bin/bash and I`m a bit confused now. I usually got this info from $SHELL variable and it shows /bin/sh. Should I assume the variable is wrong?


EDIT: Just including anwers:

Yes, installed entware and bash.
Yes, profile.add got this content right.
 
You are on a bash shell.
$SHELL gives the full path to your default shell.
$0 gives the name of your current shell.
 
SOLVED:

Add to file /opt/etc/profile:
export SHELL="/opt/bin/bash"
Thanks both of you, it's working as expected now. I still wondering why aliases won't work tho. If you have some light to shed on this topic would be more than welcome. Thanks.

Sent from my SM-N910C using Tapatalk
 
Hey @sasa1978: The .bashrc file is written to /tmp/home/root and will not survive a reboot.

What I do is copy the file at every reboot with this line in jffs/scripts/services-start:
Code:
cp /tmp/mnt/sda1/bash/.bashrc /tmp/home/root/.bashrc
 
Still not getting this to work. If I type
Code:
source ~/.bashrc
then it works, but this doesnt
Code:
rhodess@Asus-Merlin:/tmp/home/root# ~/.bashrc
bash: /root/.bashrc: Permission denied

Any ideas?
 
Code:
chmod a+rx ~/.bashrc
 
Thanks Merlin, I tried that, don’t get the error anymore but still doesn’t read .bashrc without putting source in front.
I was reading that sometimes bash does not read the file, so I was thinking I should put that in a startup script, but not sure which one I copy the .bashrc from my USB once it’s mounted, I assume that it would be OK to add a line in post-mount can you advise
 
Thanks Merlin, I tried that, don’t get the error anymore but still doesn’t read .bashrc without putting source in front.
I was reading that sometimes bash does not read the file, so I was thinking I should put that in a startup script, but not sure which one I copy the .bashrc from my USB once it’s mounted, I assume that it would be OK to add a line in post-mount can you advise
It works here, with these lines added to /opt/etc/profile
Code:
export SHELL="/opt/bin/bash"
source ~/.bashrc
Just make sure .bashrc is copied over from a persistent location to /home/root/ at every boot.
 
It works here, with these lines added to /opt/etc/profile
Code:
export SHELL="/opt/bin/bash"
source ~/.bashrc
Just make sure .bashrc is copied over from a persistent location to /home/root/ at every boot.
That worked!

Thanks for the help

BTW, I found that adding the .bashrc command below
Code:
cp /tmp/mnt/data/.bashrc /tmp/home/root/.bashrc
to
Code:
jffs/scripts/services-start
didn't always work, but adding it to
Code:
/jffs/scripts/post-mount
always works
 
Last edited:

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top