RedHat5、RedHat6、RedHat7下修改账户的默认shell类型

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 ~]$ 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值