请输入您要查询的百科知识:

 

词条 Chsh
释义

  1. Usage

  2. Portability

  3. See also

  4. References

  5. Further reading

  6. External links

{{for|the theorem in quantum mechanics|CHSH inequality}}{{lowercase}}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.[1]

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}}.[1][2][3]

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.[2][4]

Using the {{Mono|-s}} option (for example: {{Mono|% chsh -s /usr/local/bin/bash}}) 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.[4]

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|listfile=}} option to that module (along with the {{Mono|sense=deny}} option).[5]

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}}.[6] SVr4-based systems provided a similar capability with passwd. Two of the three remaining systems (AIX[7] and HP-UX[8]) 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.[9][10] The obsolete[11] SGI SVr4 system IRIX64 also lacked {{Mono|chsh}}.

See also

  • Comparison of command shells

References

1. ^{{cite book|title=Learning the Bash Shell: [Unix shell programming]|author=Cameron Newham and Bill Rosenblatt|pages=272|year=2005|publisher=O'Reilly|isbn=0596009658}}
2. ^{{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}}
3. ^{{cite book|title=Essential System Administration|author=Æleen Frisch|pages=238|year=2002|publisher=O'Reilly|isbn=0596003439}}
4. ^{{cite book|title=Unix|author=Deborah S. Ray and Eric J. Ray|pages=47|year=1998|publisher=Peachpit Press|isbn=0201353954}}
5. ^{{cite book|title=Linux System Security: The Administrator's Guide to Open Source Security Tools|author=Scott Mann and Ellen L. Mitchell|pages=101–102|year=2000|publisher=Prentice Hall PTR|isbn=0130158070}}
6. ^{{cite web |url=http://www.math.utah.edu/~beebe/unix/c/chsh.html |title=chsh command availability |author=Nelson Beebe |date=August 11, 2005 }}
7. ^{{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 }}
8. ^{{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}}
9. ^{{cite |url=http://www.linuxmisc.com/12-unix-shell/5bc090111e66f037.htm |title=chsh on Solaris |publisher=LinuxForum |author=Peter Smulder |date=March 12, 2000}}
10. ^{{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 }}
11. ^{{cite web|url=http://www.sgi.com/support/services/irix_mips_support.html |title=Archived copy |accessdate=January 24, 2015 |dead-url=yes |archiveurl=https://web.archive.org/web/20090706113422/http://www.sgi.com/support/services/irix_mips_support.html |archivedate=July 6, 2009 }}

Further reading

  • {{cite book|title=Developing Bioinformatics Computer Skills|author=Cynthia Gibas and Per Jambeck|pages=89–90|year=2001|publisher=O'Reilly|isbn=1565926641}} — 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}}

2 : Unix user management and support-related utilities|Standard Unix programs

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/10 12:19:34