Thursday, March 30, 2023

[Solved] Change default shell of a regular user in an Alpine Linux container to BASH

 When I added a regular user in Alpine Linux which is a container in LXD running on Debian Bookworm, no matter what I did, it would not use BASH. Everything was changed correctly. I changed it using chsh, I modified /etc/passwd...anytime I su - user, it would always use ash. I know bash is installed since I could enter bash and it would change shells.


Solution:

create a .profile file in $HOME

vi ~/.profile

In your .profile, add the following:

if [ -n "$BASH_VERSION" ]; then

    # include .bashrc if it exists

    if [ -f "$HOME/.bashrc" ]; then

    . "$HOME/.bashrc"

    fi

fi

Exit and log in again, and you should be using bash.