2

I want to set the login shell (the shell they get when they log in) of all existing and future users.

The correct way to change the login shell seems to be chsh. But this only allows me to change the shell of existing users.

I could put the shell command in /etc/profile, but this is also far from a clean solution.

I am using debian and want to set zsh as the default shell.

  • You could alias useradd to be useradd -s /bin/zsh :) – NickW Apr 16 '14 at 16:31
4

Depends on what you are using to add users. If it's the adduser command, then edit your /etc/adduser.conf file -- there you will find the default login shell option, namely: DSHELL.

If, on the other hand, you prefer to use useradd then use it with the -s <shell of choice> parameter.

If you wish to change the shell of existing users you can simply edit /etc/passwd and change it there. sed is a perfect choice in case you need to apply changes to numerous lines. Run sed 's/bash$/zsh/g' /etc/passwd and see what it does. You should see the contents of your /etc/passwd with every bash replaced by zsh. If you are satisfied with the result you can run the same command with -i option: sed -i 's/bash$/zsh/g' /etc/passwd. Don't forget to make a copy of the original file, just in case :)

3

I think you can set the default by editing /etc/default/useradd file and changing the SHELL= line.

1

I think useradd lets you set this: useradd -D

When invoked with only the -D option, useradd will display the current 
default values. When invoked with -D plus other options, useradd will 
update the default values for the specified options. Valid 
default-changing options are:

<...snip...>

-s, --shell SHELL
The name of a new user's login shell.
This option sets the SHELL variable in /etc/default/useradd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.