≡ Menu

How to install bash shell in Alpine Linux

How do I install bash shell in my Alpine Linux LXD (Linux Container) virtual machine (VM)?

Alpine Linux comes with BusyBox. It is described as, “The Swiss Army Knife of Embedded Linux.” BusyBox combines tiny versions of many common UNIX utilities into a single small executable including /bin/sh. By default, bash is not included with BusyBox and Alpine Linux.

How do install bash in Alpine Linux

It is easy to have bash installed but this does not mean the symlinks to busybox are gone. The syntax is:
# apk update
# apk add bash

To install bash documentation, enter:
# apk add bash-doc
To install bash automatic command line completion install, run:
# apk add bash-completion
Sample session:

Fig.01:  How to get bash working on Alpine Linux

Fig.01: How to get bash working on Alpine Linux

To use bash as a shell just type bash:
$ bash
To login to alpine Linux LXD vm from host, enter:
$ lxc exec alpine-lxd-vm-name-here bash
To change root shell to bash, enter:
# vi /etc/passwd
Find user name and the default shell such as /bin/ash:


Replace it with /bin/bash:


Customize bash shell

Here is a sample file:
cat ~/.bashrc
Sample outputs:

alias update='apk update && apk upgrade'
export HISTTIMEFORMAT="%d/%m/%y %T "
export PS1='\u@\h:\W \$ '
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
source /etc/profile.d/bash_completion.sh

See Customize the bash shell environments wiki page for more info.

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 0 comments… add one }

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , ,