How to install bash shell in Alpine Linux

How do I install bash shell in my Alpine Linux LXD (Linux Container) or 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 standard UNIX utilities into a single small executable, including /bin/sh. By default, bash is not included with BusyBox and Alpine Linux. The postmarketOS project, which is designed to run on mobile devices, is based on Alpine Linux. Many Docker images are also based upon Alpine, and you may install bash shell in Docker-based images too. This page shows how to install a bash shell in Alpine Linux using the apk command.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Alpine Linux
Est. reading time 3 mintues

How do I install bash shell in Alpine Linux?

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

Here is how it looks:

(1/4) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(2/4) Installing ncurses-libs (6.1_p20200118-r4)
(3/4) Installing readline (8.0.1-r0)
(4/4) Installing bash (5.0.17-r1)
Executing busybox-1.31.1-r19.trigger
OK: 11 MiB in 23 packages

Get a list of valid login shells on Alpine Linux using the cat command:
# cat /etc/shells

# valid login shells

How to install bash man pages and other docs

To install bash documentation, enter:
# apk add bash-doc
To install bash automatic command line completion support on Alpine Linux, 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

See “How to add/install man pages in Alpine Linux” for more information.

How to set bash as login shell

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
One can change root shell to bash shell using the following method:
# 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 displayed using the cat command cat ~/.bashrc
## OR ##
cat ~/.bash_profile

Sample config:

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/
export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e[m\] \[\e[38;5;214m\]\W\[\e[m\]\[\e[31m\]]\[\e[m\]\\$ "

See Customize the bash shell environments wiki page for more info.
bash 5.x on Alpine Linux

How to check or find bash shell version

One can type the following command:
bash --version
The current bash version:

GNU bash, version 5.0.17(1)-release (x86_64-alpine-linux-musl)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

See how to find out what shell I am using on Linux/Unix” for more info.

Adding bash to Alpine Docker image

Add the following command to your Docker config file to install bash shell:
RUN apk add --no-cache bash


You learned how to install bash shell on Alpine Linux along with documents, man pages and configure the bash shell as per your needs. I suggest you read bash man pages/docs here online for more info.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • TTTT Nov 28, 2018 @ 13:29

    It was helpful to replace sh with bash.

  • Damian Christensen Mar 12, 2021 @ 21:17

    Just started with Alpine Linux server and was missing bash badly as I am from RHEL background.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum