Change default shell: Difference between revisions

From Alpine Linux
m (Put the path to ash.)
(recommend shadow over libuser, document free-editing process)
Line 1: Line 1:
{{Note|By default Alpine Linux uses the [https://en.wikipedia.org/wiki/Almquist_shell ash] shell, but many users may prefer {{Pkg|bash}}, {{Pkg|zsh}}, {{Pkg|fish}} or another shell.}}
{{Note|By default Alpine Linux uses the busybox variant of the [https://en.wikipedia.org/wiki/Almquist_shell ash] shell, but many users may prefer {{Pkg|bash}}, {{Pkg|zsh}}, {{Pkg|fish}}, or another shell.}}
== By hand ==
Edit /etc/passwd manually. An example line is:
 
<code>user:x:1000:1000:user,,,:/home/user:/bin/ash</code>
 
Change <code>/bin/ash</code> to point to the path of a shell from <code>/etc/shells</code>.
 
== Using shadow ==


Download the required package:
Download the required package:
{{Cmd|# apk add libuser}}
{{Cmd|# apk add shadow}}
Create: <code>/etc/login.defs</code> and <code>/etc/default/useradd</code>, if you don't have them:
And use chsh:
{{Cmd|# touch /etc/login.defs}}
{{Cmd|# chsh username}}
{{Cmd|# mkdir /etc/default}}
{{Cmd|# touch /etc/default/useradd}}
Change current USER's shell:
{{Cmd|# lchsh USER}}


Now enter the path for the shell you want to use (e.g <code>/bin/bash</code>)
Now enter the path for the shell you want to use (e.g <code>/bin/bash</code>)
and press enter to confirm this change.
and press enter to confirm this change. The shell should exist in <code>/etc/shells</code>.


{{Note|You may need to log out or reboot for this change to take effect, '''ash''' is part of busybox so you can revert back to '''ash''' (/bin/ash) at anytime with the same steps.}}
{{Note|You may need to log out or reboot for this change to take effect, '''ash''' is part of busybox so you can revert back to '''ash''' (/bin/ash) at anytime with the same steps.}}

Revision as of 13:04, 12 December 2022

Note: By default Alpine Linux uses the busybox variant of the ash shell, but many users may prefer bash, zsh, fish, or another shell.

By hand

Edit /etc/passwd manually. An example line is:

user:x:1000:1000:user,,,:/home/user:/bin/ash

Change /bin/ash to point to the path of a shell from /etc/shells.

Using shadow

Download the required package:

# apk add shadow

And use chsh:

# chsh username

Now enter the path for the shell you want to use (e.g /bin/bash) and press enter to confirm this change. The shell should exist in /etc/shells.

Note: You may need to log out or reboot for this change to take effect, ash is part of busybox so you can revert back to ash (/bin/ash) at anytime with the same steps.