Change default shell: Difference between revisions

From Alpine Linux
(Created page with "==== Changing the default shell ==== Download the required package: ''apk add libuser'' If you do not have files: /etc/login.defs /etc/default/useradd We will need to creat...")
 
(correct GECOS field)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
==== Changing the default 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 {{Path|/etc/passwd}} manually. An example line for a user named <code>user</code> is:


Download the required package:
{{Cat|/etc/passwd|...
''apk add libuser''
user:x:1000:1000:user:/home/user:/bin/ash
...
}}


If you do not have files:
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.
/etc/login.defs
/etc/default/useradd


We will need to create them
== Using shadow ==


touch /etc/login.defs
Download the required package:
touch /etc/default/useradd
{{Cmd|# apk add shadow}}
And use chsh:
{{Cmd|# chsh username}}


Now we can change our default shell
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}}.


If you want to change the current user's shell:
{{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''' ({{Path|/bin/ash}}) at anytime with the same steps.}}
''lchsh''  


If you want to change a different user's shell:
[[Category:Shell]]
''lchsh USERNAME''
[[Category:Newbie]]

Latest revision as of 11:18, 10 November 2023

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 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.

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.