知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

/etc/shells文件用途

发布时间:2014-09-05 14:40:12作者:知识屋

/etc/shells文件用途
 
一直对/etc/shells这个文件的作用不是太清楚,最近抽时间查了查,总结如下。
$ man shells
SHELLS(5) Linux Programmer’s Manual SHELLS(5)
NAME
shells - pathnames of valid login shells
DESCRIPTION
/etc/shells is a text file which contains the full pathnames of valid login shells.
This file is consulted by chsh(1) and available to be queried by other programs.
Be aware that there are programs which consult this file to find out if a user is a
normal user. E.g.: ftp daemons traditionally disallow access to users with shells
not included in this file.
EXAMPLE
/etc/shells may contain the following paths:
/bin/sh
/bin/csh
FILES
/etc/shells
SEE ALSO
chsh(1), getusershell(3)
1993-11-21 SHELLS(5)
/etc/shells是一个有效登陆shell的列表,在调用chsh改变登陆shell时,会查询这个文件。
[root@winway ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
 
[winway@winway ~]$ chsh
Changing shell for winway.
口令:
New shell [/bin/bash]: /bin/date
chsh: "/bin/date" is not listed in /etc/shells.
chsh: use -l option to see list
       由于/bin/date/不在/etc/shells里,所以普通用户调用chsh失败。root调用会出现warning。
 
[root@winway ~]# echo '/bin/date' >>/etc/shells
 
[winway@winway ~]$ chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
/bin/date
[winway@winway ~]$ chsh
Changing shell for winway.
口令:
New shell [/bin/bash]: /bin/date
Shell changed.
[winway@winway ~]$ grep 'winway' /etc/passwd
winway:x:500:500:ww,isrc,no,no:/home/winway:/bin/date
另外一些程序会根据这个文件来判断一个用户是否是有效用户,例如FTP服务会组织那些shell不在/etc/shells里的用户登陆。
 
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜