The FreeBSD Diary
Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link.
Changing the shell for existing users and new users 11 August 2000
|Sometimes you just want a change. Sometimes you want that change to be permanent. And you don't want to have to make that change again.|
Changing the shell for all existing users
|icmpecho gave us this script. To change the shell to bash
for all existing users do this as root :
cd /usr/home && for i in *;do chsh -s bash $i;done
Changing the shell for all future users
|When you add a new user, the default shell is taken from /etc/adduser.conf.
On a new box, this file doesn't exist until you run adduser once.
So I ran adduser. Note that I could have specified a different bash shell.
See the bold line below. Instead, I chose to modify /etc/adduser.conf
manually. See below for those steps.
# adduser /etc/adduser.conf: No such file or directory Use option ``-silent'' if you don't want to see all warnings and questions. Check /etc/shells Check /etc/master.passwd Check /etc/group Enter your default shell: bash csh date no sh tcsh [sh]: Your default shell is: sh -> /bin/sh Enter your default HOME partition: [/home]: Copy dotfiles from: /usr/share/skel no [/usr/share/skel]: Send message from file: /etc/adduser.message no [/etc/adduser.message]: Create ``/etc/adduser.message''? (y/n) [y]: Use passwords (y/n) [y]: Write your configuration to /etc/adduser.conf? (y/n) [y]: Ok, let's go. Don't worry about mistakes. I will give you the chance later to correct any input. Enter username [a-z0-9_-]: deleteme Enter full name : deleteme Enter shell bash csh date no sh tcsh [sh]: Enter home directory (full path) [/home/deleteme]: Uid : Enter login class: default : Login group deleteme [deleteme]: Login group is ``deleteme''. Invite deleteme into other groups: guest no [no]: Enter password : Use an empty password? (y/n) [y]: Name: deleteme Password: **** Fullname: deleteme Uid: 1002 Gid: 1002 (deleteme) Class: Groups: deleteme HOME: /home/deleteme Shell: /bin/sh OK? (y/n) [y]: Added user ``deleteme'' Send message to ``deleteme'' and: no root second_mail_address [no]: deleteme, your account ``deleteme'' was created. Have fun! See also chpass(1), finger(1), passwd(1) Add anything to default message (y/n) [n]: Send message (y/n) [y]: Copy files from /usr/share/skel to /home/deleteme Add another user? (y/n) [y]: n Goodbye!
Then I changed the default shell entry in /etc/adduser.conf:
# defaultshell if not empty ("bash") defaultshell = "bash"
The next time you run adduser, you'll find this:
# adduser deleteme2 Use option ``-silent'' if you don't want to see all warnings and questions. Check /etc/shells Check /etc/master.passwd Check /etc/group Enter your default shell: bash csh date no sh tcsh [bash]: ^C [root@set:~] #
See? The default shell is now bash.
Then I went back to delete the user I added above:
[root@set:~] # rmuser deleteme Matching password entry: deleteme::1002:1002::0:0:deleteme:/home/deleteme:/bin/sh Is this the entry you wish to remove? yes Remove user's home directory (/home/deleteme)? yes Updating password file, updating databases, done. Updating group file: (removing group deleteme -- personal group is empty) done. Removing user's home directory (/home/deleteme): done. Removing user's incoming mail file /var/mail/deleteme: done. Removing files belonging to deleteme from /tmp: done. Removing files belonging to deleteme from /var/tmp: done. Removing files belonging to deleteme from /var/tmp/vi.recover: done.