Change a user's default shell

Author: name contact BSD flavour

Reviewer: name contact BSD flavour

Reviewer: name contact BSD flavour


Concept

Know the default shells for both user accounts and the superuser account for each BSD. In addition, know how to change the default shell for each BSD operating system.

Introduction

BSD systems historically use the standard C shell (/bin/csh) as root's login shell. OpenBSD uses /bin/ksh for both the root and regular user's shells.

TODO: should C shell be spelled out? Or called Csh? or csh?

If no shell is set (the 7th field in the passwd database is empty), then login and some other programs will default to standard /bin/sh.

Many system users use /sbin/nologin as the default shell. This utility will simply exit after outputting "This account is currently not available." (Note: On FreeBSD, the nologin(8) utility is located at /usr/sbin/nologin.)

The standard tool for changing the user's login shell is chsh(1). (It is a link to chpass(1).) Running the chsh utility will start up your preferred editor where the user can modify the selected shell (and other user database information).

The chsh program is setuid root, so it runs with root's privilege so it can modify the user databases. TODO: should this setuid be noted here?

TODO: should this cover EDITOR or VISUAL here? Or point to which topic page?

TODO: what systems don't default to vi for VISUAL or EDITOR??

The vipw tool can also be used to manually edit the master.passwd database and related user databases. See section Protect authentication data for details.

TODO: show how to use chsh from command line without using editor. Do all BSDs support that?

TODO: show how to use pw (FreeBSD and DragonFly) to set shell and show how to use "usermod" (NetBSD and OpenBSD) for this. Or maybe not as is covered in another section.

TODO: point to section Create, modify and remove user accounts and 'Lock a user account or reset a locked user account. Put these four sections next to each other in book

Examples

Practice Exercises

More information

vipw(8); chpass(1), chfn(1), chsh(1), pw(8), user(8)