I am new to openwrt
as soon as I login to machine and check shell using below command
echo $SHELL
---> /bin/ash
Then I type the command bash to start bash shell . even after that I check shell and result is same.
echo $SHELL
---> /bin/ash
How to start Bash shell ?
have you installed the bash package ?
yes
root@OpenWrt:~# opkg install bash
Package bash (5.1-2) installed in root is up to date.
root@OpenWrt:~#
yes
root@OpenWrt:~#
root@OpenWrt:~# bash
root@OpenWrt:~# echo $SHELL
/bin/ash
root@OpenWrt:~#
mk24
June 25, 2024, 2:23pm
6
If you want to make bash the default shell, change /bin/sh to link to bash.
1 Like
efahl
June 25, 2024, 3:33pm
7
Or edit /etc/passwd
so the root shell is bash?
$ grep root /etc/passwd
root:x:0:0:root:/root:/bin/ash
3 Likes
slh
June 25, 2024, 10:56pm
8
…just be aware that setting a non-default shell as login shell introduces a rather high risk of locking yourself out after a sysupgrade, as your new(ly installed) image won't ship with bash installed, while root's shell references /bin/bash
.
Possible, but not recommended (and even less recommended would be touching the /bin/sh
symlink, which could end you up in even more tricky situations).
6 Likes
You have to run bash <your command here>
for it to work without having to modify anything in your system. For example, bash ./test.sh
But if it's included in a custom image... Why not
Maybe if I would write bash scripts... but for OpenWrt I tend to stick and use only posix features.
1 Like
j_s
May 3, 2025, 8:06pm
11
root@turris:~# echo $SHELL
/bin/ash
root@turris:~# /bin/bash
root@turris:~# export SHELL=/bin/bash
root@turris:~# echo $SHELL
/bin/bash
root@turris:~#
I've been doing this for years on systems that I don't manage myself that have csh as the default shell.
Is there any downside to using the following in ~/.profile
:
if [ -x /bin/bash ] && [ "$0" != "/bin/bash" ]; then
exec /bin/bash
fi