Chsh
{{for|the theorem in quantum mechanics|CHSH inequality}}
{{lowercase}}
{{Infobox Software
| 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 {{Mono|chsh}} allows the user to change the shell interactively.{{cite book|title=Learning the Bash Shell: [Unix shell programming]|url=https://archive.org/details/learningbashshel00newh_697|url-access=limited|author=Cameron Newham and Bill Rosenblatt|pages=[https://archive.org/details/learningbashshel00newh_697/page/n289 272]|year=2005|publisher=O'Reilly|isbn=0596009658}}
Usage
{{Mono|chsh}} is a setuid program that modifies the {{Mono|/etc/passwd}} 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 {{Mono|/etc/shells}} 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 {{Mono|/etc/shells}} and without using {{Mono|chsh}}.{{cite book|title=A Practical Guide To Unix For Mac Os X Users|author=Mark G. Sobell and Peter Seebach|pages=448|year=2005|publisher=Prentice Hall PTR|isbn=0131863339}}{{cite book|title=Essential System Administration|url=https://archive.org/details/essentialsystema00fris_0|url-access=registration|author=Æleen Frisch|pages=238|year=2002|publisher=O'Reilly|isbn=0596003439}}
On most systems, when {{Mono|chsh}} is invoked without the {{Mono|-s}} 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 {{Mono|-s}} option, {{Mono|chsh}} 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.{{cite book|title=Unix|author=Deborah S. Ray and Eric J. Ray|pages=[https://archive.org/details/unix00rayd/page/47 47]|year=1998|publisher=Peachpit Press|isbn=0201353954|url=https://archive.org/details/unix00rayd/page/47}}
Using the {{Mono|-s}} option (for example: {{code|% chsh -s /usr/local/bin/bash|console}}) greatly simplifies the task of changing shells.
Depending on the system, {{Mono|chsh}} may or may not prompt the user for a password before changing the shell, or entering interactive mode. On some systems, use of {{Mono|chsh}} by non-root users is disabled entirely by the sysadmin.
On many Linux distributions, the {{Mono|chsh}} command is a PAM-aware application. As such, its behaviour can be tailored, using PAM configuration options, for individual users. For example, an {{Mono|auth}} directive that specifies the {{Mono|pam_listfile.so}} module can be used to deny {{Mono|chsh}} access to individual users, by specifying a file of the usernames to deny access to with the {{Mono|1=listfile=}} option to that module (along with the {{Mono|1=sense=deny}} option).{{cite book|title=Linux System Security: The Administrator's Guide to Open Source Security Tools|author=Scott Mann and Ellen L. Mitchell|pages=[https://archive.org/details/linuxsystemsecur00mann/page/101 101–102]|year=2000|publisher=Prentice Hall PTR|isbn=0130158070|url=https://archive.org/details/linuxsystemsecur00mann/page/101}}
Portability
POSIX does not describe utilities such as {{Mono|chsh}}, which are used for modifying the user's entry in {{Mono|/etc/passwd}}. Most Unix-like systems provide {{Mono|chsh}}.{{cite web |url=http://www.math.utah.edu/~beebe/unix/c/chsh.html |title=chsh command availability |author=Nelson Beebe |date=August 11, 2005 }} SVr4-based systems provided a similar capability with passwd. Two of the three remaining systems (IBM AIX{{cite web |url=http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.cmds1/chsh.htm |title=IBM Knowledge Center chsh command |publisher=IBM |accessdate=January 24, 2015 }} and HP-UX{{cite web |url=http://h20565.www2.hp.com/hpsc/doc/public/display?docId=emr_na-c02258736 |title=chsh(1) |publisher=Hewlett Packard |accessdate=January 24, 2015 |archive-url=https://web.archive.org/web/20150128112939/http://h20565.www2.hp.com/hpsc/doc/public/display?docId=emr_na-c02258736 |archive-date=January 28, 2015 |url-status=dead }}) provide {{Mono|chsh}} in addition to {{Mono|passwd -e}}. 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.{{citation |url=http://www.linuxmisc.com/12-unix-shell/5bc090111e66f037.htm |title=chsh on Solaris |publisher=LinuxForum |author=Peter Smulder |date=March 12, 2000}}{{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{{cite web|url=http://www.sgi.com/support/services/irix_mips_support.html |title=SGI - Services & Support: SGI Support of MIPS IRIX Products Continues to December 2013 |accessdate=January 24, 2015 |url-status=dead |archiveurl=https://web.archive.org/web/20090706113422/http://www.sgi.com/support/services/irix_mips_support.html |archivedate=July 6, 2009}} SGI SVr4 system IRIX64 also lacked {{Mono|chsh}}.
See also
References
{{Reflist}}
Further reading
- {{cite book|title=Developing Bioinformatics Computer Skills|author=Cynthia Gibas and Per Jambeck|pages=[https://archive.org/details/developingbioinf00giba_0/page/89 89–90]|year=2001|publisher=O'Reilly|isbn=1565926641|url=https://archive.org/details/developingbioinf00giba_0/page/89}} — some examples of invoking {{Mono|chsh}} with the {{Mono|-s}} and {{Mono|-l}} options
External links
{{wikibooks|Guide to Unix|Explanations/Choice of Shell|Choosing a shell}}
- {{man|1|chsh|4.2BSD}}
- {{man|1|chsh|die.net|change your login shell}}
- {{apple man page|chsh}}
- {{man|1|passwd|Solaris}}
{{Unix commands}}