Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buildroot: change default root shell

Tags:

buildroot

We've added bash to our buildroot configuration and would now like to make it the default shell for the root user. I'd prefer not to add a passwd file to our overlay so is there some way through buildroot's config to make the root shell default to /bin/bash rather than /bin/sh?

like image 795
cake_in_a_bag Avatar asked Nov 26 '25 12:11

cake_in_a_bag


1 Answers

You can set the shell for all users to bash by setting BR2_SYSTEM_BIN_SH_BASH, i.e. in menuconfig set System configuration -> /bin/sh to bash. This will generate /bin/sh as a symlink to bash.

To set it for the root user only, you'll need a post-build script such as:

#!/bin/sh
sed -i '/^root:/s,:/bin/sh$,:/bin/bash,' ${TARGET_DIR}/etc/passwd
like image 148
Luca Ceresoli Avatar answered Nov 28 '25 17:11

Luca Ceresoli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!