Change default shell: Difference between revisions

From Alpine Linux
No edit summary
m (rephrased sentence. moved the note to front.)
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==== Changing the default shell ====
Alpine Linux uses the [[BusyBox]] variant of the [[BusyBox#Ash_shell|ash]] shell. This page explains various ways to change the default shell in Alpine Linux to other popular shells like {{Pkg|bash}}, {{Pkg|zsh}}, {{Pkg|fish}} etc.. You can revert back to '''ash shell''' at anytime with the same steps.


'''Download the required package:'''
{{Note|You need to log out and login again for these changes to take effect.}}
<br>
''apk add libuser''
<br><br>
If you do not have files:
* /etc/login.defs
* /etc/default/useradd


We will need to create them
== By hand ==
Edit {{Path|/etc/passwd}} manually. An example line for a user named <code>user</code> is:


''touch /etc/login.defs''
{{Cat|/etc/passwd|...
<br>
user:x:1000:1000:user:/home/user:/bin/ash
''touch /etc/default/useradd''
...
<br><br>
}}
Now we can change our default shell
 
<br><br>
Change {{Path|/bin/ash}} to point to the path of a shell from {{Path|/etc/shells}}. Take care to not delete/mangle the line, as it would make you unable to log in again. The <code>user</code> should be the user you are changing the default login shell for.
If you want to change the current user's shell:<br>
 
''lchsh''
== Using shadow ==
<br>
 
If you want to change a different user's shell:<br>
Download the required package:
''lchsh USERNAME''
{{Cmd|# apk add shadow}}
And use chsh:
{{Cmd|# chsh username}}
 
Now enter the path for the shell you want to use (e.g {{Path|/bin/bash}})
and press {{Key|Enter}} to confirm this change. The shell should exist in {{Path|/etc/shells}}.
 
[[Category:Shell]]
[[Category:System Administration]]

Latest revision as of 09:52, 22 October 2024

Alpine Linux uses the BusyBox variant of the ash shell. This page explains various ways to change the default shell in Alpine Linux to other popular shells like bash, zsh, fish etc.. You can revert back to ash shell at anytime with the same steps.

Note: You need to log out and login again for these changes to take effect.

By hand

Edit /etc/passwd manually. An example line for a user named user is:

Contents of /etc/passwd

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

Change /bin/ash to point to the path of a shell from /etc/shells. Take care to not delete/mangle the line, as it would make you unable to log in again. The user should be the user you are changing the default login shell for.

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.