Chsh
Command on Unix-like operating systems
title: "Chsh" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["unix-user-management-and-support-related-utilities", "standard-unix-programs"] description: "Command on Unix-like operating systems" topic_path: "technology/operating-systems" source: "https://en.wikipedia.org/wiki/Chsh" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Command on Unix-like operating systems ::
::data[format=table title="Infobox Software"]
| Field | Value |
|---|---|
| name | chsh |
| author | Salvatore Valente |
| operating system | Unix and Unix-like |
| genre | Command |
| :: |
| name = chsh | logo = | screenshot = | screenshot size = | caption = | author = Salvatore Valente | developer = | released = | latest release version = | latest release date = | operating system = Unix and Unix-like | genre = Command | license = | website = chsh (an abbreviation of "change shell") is a command on Unix-like operating systems that is used to change a login shell. Users can either supply the pathname of the shell that they wish to change to on the command line, or supply no arguments, in which case allows the user to change the shell interactively.
Usage
is a setuid program that modifies the file, and only allows ordinary users to modify their own login shells. The superuser can modify the shells of other users, by supplying the name of the user whose shell is to be modified as a command-line argument. For security reasons, the shells that both ordinary users and the superuser can specify are limited by the contents of the file, with the pathname of the shell being required to be exactly as it appears in that file. (This security feature is alterable by re-compiling the source code for the command with a different configuration option, and thus is not necessarily enabled on all systems.) The superuser can, however, also modify the password file directly, setting any user's shell to any executable file on the system without reference to and without using .
On most systems, when is invoked without the command-line option (to specify the name of the shell), it prompts the user to select one. On Mac OS X, if invoked without the option, displays a text file in the default editor (initially set to vim) allowing the user to change all of the features of their user account that they are permitted to change, the pathname of the shell being the name next to "Shell:". When the user quits vim, the changes made there are transferred to the /etc/passwd file which only root can change directly.
Using the option (for example: ) greatly simplifies the task of changing shells.
Depending on the system, may or may not prompt the user for a password before changing the shell, or entering interactive mode. On some systems, use of by non-root users is disabled entirely by the sysadmin.
On many Linux distributions, the command is a PAM-aware application. As such, its behaviour can be tailored, using PAM configuration options, for individual users. For example, an directive that specifies the module can be used to deny access to individual users, by specifying a file of the usernames to deny access to with the option to that module (along with the option).
Portability
POSIX does not describe utilities such as , which are used for modifying the user's entry in . Most Unix-like systems provide . SVr4-based systems provided a similar capability with passwd. Two of the three remaining systems (IBM AIX and HP-UX) provide in addition to . The exception is Solaris, where non-administrators are unable to change their shell unless a network name server such as NIS or NIS+ is installed.{{cite web |url=http://www.linuxmisc.com/3-solaris/553ca643a95af24f.htm |title=User chsh shell change function needed for Solaris |publisher=LinuxForum |author=Henry van Cleef |date=February 4, 2005 }} The obsolete SGI SVr4 system IRIX64 also lacked .
References
References
- Cameron Newham and Bill Rosenblatt. (2005). "Learning the Bash Shell: [Unix shell programming]". O'Reilly.
- Mark G. Sobell and Peter Seebach. (2005). "A Practical Guide To Unix For Mac Os X Users". Prentice Hall PTR.
- Æleen Frisch. (2002). "Essential System Administration". O'Reilly.
- Deborah S. Ray and Eric J. Ray. (1998). "Unix". Peachpit Press.
- Scott Mann and Ellen L. Mitchell. (2000). "Linux System Security: The Administrator's Guide to Open Source Security Tools". Prentice Hall PTR.
- Nelson Beebe. (August 11, 2005). "''chsh'' command availability".
- "IBM Knowledge Center chsh command". IBM.
- "chsh(1)". Hewlett Packard.
- Peter Smulder. (March 12, 2000). "chsh on Solaris". LinuxForum.
- "SGI - Services & Support: SGI Support of MIPS IRIX Products Continues to December 2013".
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::