# How to start bash shell in openwrt

**URL:** <https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079>\
**Category:** Installing and Using OpenWrt\
**Created:** [June 25, 2024, 2:02pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079 "2024-06-25T14:02:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![shekharsinghtomar](https://forum.openwrt.org/letter_avatar/shekharsinghtomar/32/6_449c533f586939b6e5f246632a46421f.png) [@shekharsinghtomar](https://forum.openwrt.org/u/shekharsinghtomar)\
**Post date:** [June 25, 2024, 2:02pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/1 "2024-06-25T14:02:57Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![frollic](https://forum.openwrt.org/user_avatar/forum.openwrt.org/frollic/32/30113_2.png) [@frollic](https://forum.openwrt.org/u/frollic)\
**Post date:** [June 25, 2024, 2:03pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/2 "2024-06-25T14:03:44Z")

</div>

have you installed the bash package ?

---

<div class="post-metadata">

**Author:** ![shekharsinghtomar](https://forum.openwrt.org/letter_avatar/shekharsinghtomar/32/6_449c533f586939b6e5f246632a46421f.png) [@shekharsinghtomar](https://forum.openwrt.org/u/shekharsinghtomar)\
**Post date:** [June 25, 2024, 2:04pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/3 "2024-06-25T14:04:17Z")

</div>

yes

root@OpenWrt:~# opkg install bash  
Package bash (5.1-2) installed in root is up to date.  
root@OpenWrt:~#

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/6_449c533f586939b6e5f246632a46421f.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [June 25, 2024, 2:11pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/4 "2024-06-25T14:11:47Z")

</div>

> [@shekharsinghtomar](#):
>
> root@OpenWrt:~#

Tried running `bash`?

---

<div class="post-metadata">

**Author:** ![shekharsinghtomar](https://forum.openwrt.org/letter_avatar/shekharsinghtomar/32/6_449c533f586939b6e5f246632a46421f.png) [@shekharsinghtomar](https://forum.openwrt.org/u/shekharsinghtomar)\
**Post date:** [June 25, 2024, 2:20pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/5 "2024-06-25T14:20:17Z")

</div>

yes

root@OpenWrt:~#  
root@OpenWrt:~# bash  
root@OpenWrt:~# echo $SHELL  
/bin/ash  
root@OpenWrt:~#

---

<div class="post-metadata">

**Author:** ![mk24](https://forum.openwrt.org/letter_avatar/mk24/32/6_449c533f586939b6e5f246632a46421f.png) [@mk24](https://forum.openwrt.org/u/mk24)\
**Post date:** [June 25, 2024, 2:23pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/6 "2024-06-25T14:23:43Z")

</div>

If you want to make bash the default shell, change /bin/sh to link to bash.

---

<div class="post-metadata">

**Author:** ![efahl](https://forum.openwrt.org/user_avatar/forum.openwrt.org/efahl/32/50404_2.png) [@efahl](https://forum.openwrt.org/u/efahl)\
**Post date:** [June 25, 2024, 3:33pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/7 "2024-06-25T15:33:09Z")

</div>

Or edit `/etc/passwd` so the root shell is bash?

```plaintext
$ grep root /etc/passwd
root:x:0:0:root:/root:/bin/ash

```

---

<div class="post-metadata">

**Author:** ![slh](https://forum.openwrt.org/user_avatar/forum.openwrt.org/slh/32/113591_2.png) [@slh](https://forum.openwrt.org/u/slh)\
**Post date:** [June 25, 2024, 10:56pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/8 "2024-06-25T22:56:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ronhombre](https://forum.openwrt.org/user_avatar/forum.openwrt.org/ronhombre/32/117379_2.png) [@ronhombre](https://forum.openwrt.org/u/ronhombre)\
**Post date:** [May 3, 2025, 6:53pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/9 "2025-05-03T18:53:11Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![\_bernd](https://forum.openwrt.org/user_avatar/forum.openwrt.org/_bernd/32/124645_2.png) [@\_bernd](https://forum.openwrt.org/u/_bernd)\
**Post date:** [May 3, 2025, 7:48pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/10 "2025-05-03T19:48:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![j\_s](https://forum.openwrt.org/letter_avatar/j_s/32/6_449c533f586939b6e5f246632a46421f.png) [@j\_s](https://forum.openwrt.org/u/j_s)\
**Post date:** [May 3, 2025, 8:06pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/11 "2025-05-03T20:06:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![macAttack](https://forum.openwrt.org/letter_avatar/macattack/32/6_449c533f586939b6e5f246632a46421f.png) [@macAttack](https://forum.openwrt.org/u/macAttack)\
**Post date:** [May 28, 2025, 4:33pm UTC](https://forum.openwrt.org/t/how-to-start-bash-shell-in-openwrt/202079/12 "2025-05-28T16:33:38Z")

</div>

Is there any downside to using the following in `~/.profile`:

```bash
if [-x /bin/bash] && ["$0" != "/bin/bash"]; then
    exec /bin/bash
fi

```
