redhat5、redhat6、redhat7下修改账户的默认shell类型
顾名思义,就是修改/etc/passwd配置文件的最后一列,命令解释程序(Shell)
命令1:
chsh -s /bin/false username
命令2:
usermod -s /bin/false username
命令1测试:
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.1 (Tikanga)
[root@localhost ~]# chsh -l(查看主机支持的shell类型;命令结果和cat /etc/shells一致。)
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
[root@localhost ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
[root@localhost ~]# useradd test1
[root@localhost ~]# id test1
uid=501(test1) gid=501(test1) groups=501(test1)
[root@localhost ~]# grep test /etc/passwd
test1:x:501:501::/home/test1:/bin/bash
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# chsh -s /bin/false test1
Changing shell for test1.
Warning: "/bin/false" is not listed in /etc/shells
Shell changed.
[root@localhost ~]# grep test /etc/passwd
test1:x:501:501::/home/test1:/bin/false
[root@localhost ~]#
命令2测试
[xp@localhost ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.5 (Maipo)
[xp@localhost ~]$ grep test1 /etc/passwd
test1:x:1002:1002::/home/test1:/bin/bash
[xp@localhost ~]$
[xp@localhost ~]$ sudo usermod -s /bin/false test1
[xp@localhost ~]$
[xp@localhost ~]$
[xp@localhost ~]$ grep test1 /etc/passwd
test1:x:1002:1002::/home/test1:/bin/false
[xp@localhost ~]$