alpine-wiki

alpine shell and terminal

Note: You must have alpine already installed alpine-newbie-install.md

Short answer:

In alpine the default terminal always will give you ash throught busybox pretty limited but functional enought.

Default console shell

The operation system do not have a oficial interface, could be a console one or graphical one.

Shell name package(s) name since main program(S)
bash bash bash-doc 3.0 /bin/bash, /usr/lib/bash/
dash dash dash-doc 3.17 /bin/dash
csh tcsh tcsh-doc 3.4 /bin/csh, /bin/tcsh, /etc/tcsh.cshrc
zsh zsh zsh-vcs zsh-zftp zsh-doc 3.4 /bin/zsh, /usr/lib/zsh/
fish fish fish-tools fish-dev fish-doc 3.10 /usr/bin/fish, /etc/fish/config.fish, /usr/share/fish/
nushell nushell nushell-plugins nushell-doc edge /usr/bin/nushell

change manually the default console shell

Note: no shell id installed by default, only busybox for ash

apk add bash bash-doc sed

grep bash /etc/shells

sed -e '/general/ s#\:[^\:]*$#\:/bin/bash#g' /etc/passwd

Warning: if the thirth step does not show something, you cannot use such shell (in this example bash)

This can be executed in one command as apk add bash sed && sed -e '/general/ s#\:[^\:]*$#\:"$(grep bash /etc/shells)"#g' /etc/passwd

Change managed the default shell with libuser

Note: libuser is only since alpine v3.14

apk add bash bash-doc

apk add libuser libuser-doc

touch /etc/login.defs
mkdir /etc/default/ && touch /etc/default/useradd

grep bash /etc/shells

lchsh general

Warning: if the thirth step does not show something, you cannot use such shell (in this example bash)

This program is interactive, will ask for the full path to the executable shell, and can be executed in one command as apk add bash grep libuser && lchsh general

Change managed the default shell with shadow

Note: shadow in not installed by default, only busybox

apk add bash bash-doc

apk add shadow shadow-doc

touch /etc/login.defs
mkdir /etc/default/ && touch /etc/default/useradd

grep bash /etc/shells

chsh -s /bin/bash general

Warning: if the thirth step does not show something, you cannot use such shell (in this example bash)

This can be executed in one command as apk add bash grep shadow && chsh -s $(grep bash /etc/shells) general

error of not valid shel or the shell program does not exist

This was a big bug in alpine versions: https://gitlab.alpinelinux.org/alpine/aports/-/issues/11164

In each of the options of this document whe put a stepp that said: “Check dessired shell is system valid”, well each shell must be present in the file /etc/shells before apply.

Note: If the shell is compiled manually and is not packaged, you can add into the file!

how to add a more recent version

This depends, check various examples:

This means you will:

By example this show you how to install nushell into alpine 3.17 or 3.18 that is close to edge (as 2023):

cat > /etc/apk/repositories << EOF; $(echo)
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community
EOF

apk update && apk add shadow shadow-doc grep busybox-binsh libcrypto3 libgcc libssl3 sqlite-libs

cat > /etc/apk/repositories << EOF; $(echo)
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
EOF

apk update && apk add nushell nushell-plugins nushell-doc

touch /etc/login.defs && mkdir /etc/default/ && touch /etc/default/useradd

chsh -s $(grep nushell /etc/shells) general

cat > /etc/apk/repositories << EOF; $(echo)
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community
EOF

apk update

CC BY-NC-SA: If you remix, adapt, or build upon the material, you must license the modified material under identical terms, includes the following elements:

Please check our ../alpine/copyright.md.