Linux基础之passwd ,shadow

Linux基础之passwd,shadow

1 /etc/passwd

新建test用户

[root@centos1 ~]#getent passwd test   # getent查看passwd某个用户
test:x:1015:1015:userinfo:/home/test:/bin/bash
 1   2   3    4     5         6           7 
  1. login name:登录用户(test)

  2. passwd:密码(x)

    密码字段为x表示密码存在于shadow中可用pwunconv,pwconv修改,psswd文件 普通用户也可以查看,为了安全不要修改

    [root@centos1 ~]#pwunconv
    [root@centos1 ~]#getent passwd test
    test:$6$diwWXYbX$pmRSwY3L7AMIgdtaGbvu7zjgfU61YSyvHVZQ1dwQkrLC76KnQp06elWWDKe6vBjfYfxFfoFQD4JVHuBfHokkb0:1015:1015:userinfo:/home/test:/bin/bash  $6表示加密算法为sha512
    
  3. UID:用户身份编号(1015)

  4. GID:登录默认所在组编号(1015)

    UID和GID再CentOS7默认为1000以上,CentOS6中默认为500以上,可在cat /etc/login.defs查看

  5. ECOS:用户全名或注释
    用户的全名和一些信息,可用finger查看(如果没有该命令需安装)chfn命令可以修改这些信息

    [root@centos1 default]#finger test
    Login: test                    Name: userinfo
    Directory: /home/test                  Shell: /bin/bash
    Never logged in.
    No mail.
    No Plan.  
    
  6. home directory:用户主目录 (/home/test)

  7. shell:用户默认使用shell (/bin/bash) 默认shell 可用chsh修改 chsh -s /sbin/nologin test 测试完要改回来

2 /etc/shadow

[root@centos1 ~]#getent shadow test
test:!!:18042:0:99999:2:10:18408:
 1   2    3   4    5  6  7   8
  1. 登录用名

  2. 用户密码:一般用sha512加密 !!表示密码为空账户被锁定

  3. 从1970年1月1日起到密码最近一次被更改的时间

  4. 密码再过几天可以被变更(0表示随时可被变更)

  5. 密码再过几天必须被变更(99999表示永不过期)

  6. 密码过期前几天系统提醒用户(默认为一周)

  7. 密码过期几天后帐号会被锁定

  8. 从1970年1月1日算起,多少天后帐号失效

chage [OPTION]… LOGIN
-d LAST_DAY
-E --expiredate EXPIRE_DATE
-I --inactive INACTIVE
-m --mindays MIN_DAYS
-M --maxdays MAX_DAYS
-W --warndays WARN_DAYS
-l 显示密码策略

 可逐个修改体会各字段对应的含义
[root@centos1 data]$getent shadow test
test:!!:18042:0:99999:7:3::
[root@centos1 data]#chage -l test   查看密码策略
Last password change                    : May 26, 2019
Password expires                    : never
Password inactive                   : never
Account expires                     : never
Minimum number of days between password change      : 0
Maximum number of days between password change      : 99999
Number of days of warning before password expires   : 7

转载于:https://blog.51cto.com/14322729/2400374

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值