Linux用户及组管理类命令总结及演示

groupadd,useradd,passwd,gpasswd,id,su

groupadd
  • image.png
  • 命令演示
    [root@localhost ~]# tail /etc/group
    tail /etc/group
    rpcuser:x:29:
    nfsnobody:x:65534:
    gnome-initial-setup:x:985:
    stapusr:x:156:
    stapsys:x:157:
    stapdev:x:158:
    slocate:x:21:
    ntp:x:38:
    avahi:x:70:
    tcpdump:x:72:
    [root@localhost ~]#
    [root@localhost ~]# groupadd redhat
    [root@localhost ~]# tail -1 /etc/group
    redhat:x:1000:
    [root@localhost ~]# groupadd -g 1010 redhat1
    [root@localhost ~]# tail -2 /etc/group
    redhat:x:1000:
    redhat1:x:1010:
    [root@localhost ~]# groupadd redhat2
    [root@localhost ~]# tail -3 /etc/group
    redhat:x:1000:
    redhat1:x:1010:
    redhat2:x:1011:
    [root@localhost ~]# groupadd -r sysred
    [root@localhost ~]# tail -3 /etc/group
    redhat1:x:1010:
    redhat2:x:1011:
    sysred:x:984:
    [root@localhost ~]# groupadd -r sysred1
    [root@localhost ~]# tail -3 /etc/group
    redhat2:x:1011:
    sysred:x:984:
    sysred1:x:983:
groupmod
  • image.png
  • 命令演示
    [root@localhost ~]# tail -5 /etc/group
    redhat:x:1000:
    redhat1:x:1010:
    redhat2:x:1011:
    sysred:x:984:
    sysred1:x:983:
    [root@localhost ~]# groupmod -g 1001 redhat
    [root@localhost ~]# tail -5 /etc/group
    redhat:x:1001:
    redhat1:x:1010:
    redhat2:x:1011:
    sysred:x:984:
    sysred1:x:983:
    [root@localhost ~]# groupmod -n redhat3 redhat2
    [root@localhost ~]# tail -5 /etc/group
    redhat:x:1001:
    redhat1:x:1010:
    sysred:x:984:
    sysred1:x:983:
    redhat3:x:1011:
    [root@localhost ~]#

groupdel
  • image.png
  • 命令演示
    [root@localhost ~]# groupdel redhat
    [root@localhost ~]# tail -5 /etc/group
    tcpdump:x:72:
    redhat1:x:1010:
    sysred:x:984:
    sysred1:x:983:
    redhat3:x:1011:
    [root@localhost ~]# groupdel redhat1
    [root@localhost ~]# groupdel redhat3
    [root@localhost ~]# groupdel sysred
    [root@localhost ~]# groupdel sysred1
    [root@localhost ~]# tail -5 /etc/group
    stapdev:x:158:
    slocate:x:21:
    ntp:x:38:
    avahi:x:70:
    tcpdump:x:72:
    [root@localhost ~]#

useradd
  • image.png
  • 命令演示
    [root@localhost ~]# tail -5 /etc/passwd
    nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
    gnome-initial-setup:x:990:985::/run/gnome-initial-setup/:/sbin/nologin
    ntp:x:38:38::/etc/ntp:/sbin/nologin
    avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
    tcpdump:x:72:72::/:/sbin/nologin
    [root@localhost ~]# useradd centos
    [root@localhost ~]# useradd -u 1005 fedora
    [root@localhost ~]# useradd suse
    [root@localhost ~]# !tail
    tail -5 /etc/passwd
    avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
    tcpdump:x:72:72::/:/sbin/nologin
    centos:x:1000:1000::/home/centos:/bin/bash
    fedora:x:1005:1005::/home/fedora:/bin/bash
    suse:x:1006:1006::/home/suse:/bin/bash
    [root@localhost ~]# groupadd redhat
    [root@localhost ~]# groupadd redhat1
    [root@localhost ~]# tail -5 /etc/group
    centos:x:1000:
    fedora:x:1005:
    suse:x:1006:
    redhat:x:1007:
    redhat1:x:1008:
    [root@localhost ~]# id centos
    uid=1000(centos) gid=1000(centos) 组=1000(centos)
    [root@localhost ~]# useradd -G redhat,redhat1 centos
    useradd:用户“centos”已存在
    [root@localhost ~]# id centos
    uid=1000(centos) gid=1000(centos) 组=1000(centos)
    [root@localhost ~]# useradd -G redhat,redhat1 rhel
    [root@localhost ~]# id rhel
    uid=1007(rhel) gid=1009(rhel) 组=1009(rhel),1007(redhat),1008(redhat1)
    [root@localhost ~]# useradd -c 'i am a family of redhat' centos1
    [root@localhost ~]# tail -1 /etc/passwd
    centos1:x:1008:1010:i am a family of redhat:/home/centos1:/bin/bash
    [root@localhost ~]# mkdir /tmp/centos2
    [root@localhost ~]# ls -a /tmp/centos2
    . ..
    [root@localhost ~]# useradd -d /tmp/centos2 centos2
    useradd:警告:此主目录已经存在。
    不从 skel 目录里向其中复制任何文件。
    [root@localhost ~]# tail -1 /etc/passwd
    centos2:x:1009:1011::/tmp/centos2:/bin/bash
    [root@localhost ~]# ls -a /tmp/centos2
    . ..
    [root@localhost tmp]# ls -d /tmp/cent*
    /tmp/centos2
    [root@localhost tmp]# useradd -d /tmp/centos3 centos3
    useradd: cannot set SELinux context for home directory /tmp/centos3
    [root@localhost tmp]# setenforce 0
    [root@localhost tmp]# useradd -d /tmp/centos3 centos3
    useradd:用户“centos3”已存在
    [root@localhost tmp]# ls -d /tmp/cent*
    /tmp/centos2
    [root@localhost tmp]# tail -1 /etc/passwd
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    [root@localhost tmp]# userdel -r centos3
    userdel: centos3 邮件池 (/var/spool/mail/centos3) 未找到
    userdel:未找到 centos3 的主目录“/tmp/centos3”
    [root@localhost tmp]# useradd -d /tmp/centos3 centos3
    [root@localhost tmp]# ls -d /tmp/cent*
    /tmp/centos2 /tmp/centos3
    [root@localhost tmp]# ls -a /tmp/centos3/
    . .. .bash_logout .bash_profile .bashrc .mozilla
    [root@localhost tmp]# ls -a /etc/skel/
    . .. .bash_logout .bash_profile .bashrc .mozilla
    [root@localhost tmp]# tail -2 /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1008:1010:i am a family of redhat:/home/centos1:/bin/bash
    centos2:x:1009:1011::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    [root@localhost ~]# cd ~centos2
    [root@localhost centos2]# pwd
    /tmp/centos2
    [root@localhost centos2]# ll -d
    drwxr-xr-x. 2 root root 6 7月 25 22:05 .
    [root@localhost centos2]# cd ~centos3
    [root@localhost centos3]# pwd
    /tmp/centos3
    [root@localhost centos3]# ll -d
    drwx------. 3 centos3 centos3 78 7月 25 22:21 .
    [root@localhost ~]# useradd -M centos4
    [root@localhost ~]# ll /home
    总用量 0
    drwx------. 3 centos centos 78 7月 25 21:56 centos
    drwx------. 3 centos1 centos1 78 7月 25 22:04 centos1
    drwx------. 3 fedora fedora 78 7月 25 21:56 fedora
    drwx------. 3 rhel rhel 78 7月 25 22:02 rhel
    drwx------. 3 suse suse 78 7月 25 21:57 suse
    [root@localhost ~]# tail -2 /etc/passwd
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/home/centos4:/bin/bash
    [root@localhost ~]# cd ~centos4
    -bash: cd: /home/centos4: 没有那个文件或目录
    [root@localhost ~]# cat /etc/shells
    /bin/sh
    /bin/bash
    /sbin/nologin
    /usr/bin/sh
    /usr/bin/bash
    /usr/sbin/nologin
    /bin/tcsh
    /bin/csh
    [root@localhost ~]# useradd -s /bin/sh centos5
    [root@localhost ~]# tail -2 /etc/passwd
    centos4:x:1011:1013::/home/centos4:/bin/bash
    centos5:x:1012:1014::/home/centos5:/bin/sh
    [root@localhost ~]# useradd -s /bin/zsh centos6
    [root@localhost ~]# tail -2 /etc/passwd
    centos5:x:1012:1014::/home/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    [root@localhost ~]# useradd -r syscent
    [root@localhost ~]# tail -2 /etc/passwd
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    [root@localhost ~]# useradd -D
    GROUP=100
    HOME=/home
    INACTIVE=-1
    EXPIRE=
    SHELL=/bin/bash
    SKEL=/etc/skel
    CREATE_MAIL_SPOOL=yes
    [root@localhost ~]# useradd -D -b /tmp
    [root@localhost ~]# useradd -D -f 0
    [root@localhost ~]# useradd -D -s /etc/csh
    [root@localhost ~]# useradd -D
    GROUP=100
    HOME=/tmp
    INACTIVE=0
    EXPIRE=
    SHELL=/etc/csh
    SKEL=/etc/skel
    CREATE_MAIL_SPOOL=yes
    [root@localhost ~]# useradd centos7
    [root@localhost ~]# tail -2 /etc/passwd
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# useradd -D -s /etc/bash
    [root@localhost ~]# useradd -D -b /home
    [root@localhost ~]# useradd -D -s /etc/bash
    [root@localhost ~]# useradd -D -f -1
    [root@localhost ~]# useradd -D
    GROUP=100
    HOME=/home
    INACTIVE=-1
    EXPIRE=
    SHELL=/etc/bash
    SKEL=/etc/skel
    CREATE_MAIL_SPOOL=yes
    [root@localhost ~]# cat /etc/default/useradd
    # useradd defaults file
    GROUP=100
    HOME=/home
    INACTIVE=-1
    EXPIRE=
    SHELL=/etc/bash
    SKEL=/etc/skel
    CREATE_MAIL_SPOOL=yes
     
    [root@localhost ~]#

usermod
  • image.png
  • 命令演示
    [root@localhost ~]# tail /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1008:1010:i am a family of redhat:/home/centos1:/bin/bash
    centos2:x:1009:1011::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/home/centos4:/bin/bash
    centos5:x:1012:1014::/home/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# usermod -u 1018 centos1
    [root@localhost ~]# tail /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1018:1010:i am a family of redhat:/home/centos1:/bin/bash
    centos2:x:1009:1011::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/home/centos4:/bin/bash
    centos5:x:1012:1014::/home/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# usermod -g redhat centos1
    [root@localhost ~]# usermod -g 1007 centos2
    [root@localhost ~]# tail /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1018:1007:i am a family of redhat:/home/centos1:/bin/bash
    centos2:x:1009:1007::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/home/centos4:/bin/bash
    centos5:x:1012:1014::/home/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# id centos1
    uid=1018(centos1) gid=1007(redhat) 组=1007(redhat)
    [root@localhost ~]# usermod -G centos centos1
    [root@localhost ~]# id centos1
    uid=1018(centos1) gid=1007(redhat) 组=1007(redhat),1000(centos)
    [root@localhost ~]# tail -15 /etc/group
    tcpdump:x:72:
    centos:x:1000:centos1
    fedora:x:1005:
    suse:x:1006:
    redhat:x:1007:rhel
    redhat1:x:1008:rhel
    rhel:x:1009:
    centos1:x:1010:
    centos2:x:1011:
    centos3:x:1012:
    centos4:x:1013:
    centos5:x:1014:
    centos6:x:1015:
    syscent:x:984:
    centos7:x:1016:
    [root@localhost ~]# id centos1
    uid=1018(centos1) gid=1007(redhat) 组=1007(redhat),1000(centos)
    [root@localhost ~]# usermod -G rhel centos1
    [root@localhost ~]# id centos1
    uid=1018(centos1) gid=1007(redhat) 组=1007(redhat),1009(rhel)
    [root@localhost ~]# tail -15 /etc/group
    tcpdump:x:72:
    centos:x:1000:
    fedora:x:1005:
    suse:x:1006:
    redhat:x:1007:rhel
    redhat1:x:1008:rhel
    rhel:x:1009:centos1
    centos1:x:1010:
    centos2:x:1011:
    centos3:x:1012:
    centos4:x:1013:
    centos5:x:1014:
    centos6:x:1015:
    syscent:x:984:
    centos7:x:1016:
    [root@localhost ~]# usermod -aG redhat centos1
    [root@localhost ~]# usermod -aG 1000 centos1
    [root@localhost ~]# id centos1
    uid=1018(centos1) gid=1007(redhat) 组=1007(redhat),1000(centos),1009(rhel)
    [root@localhost ~]# tail -15 /etc/group
    tcpdump:x:72:
    centos:x:1000:centos1
    fedora:x:1005:
    suse:x:1006:
    redhat:x:1007:rhel,centos1
    redhat1:x:1008:rhel
    rhel:x:1009:centos1
    centos1:x:1010:
    centos2:x:1011:
    centos3:x:1012:
    centos4:x:1013:
    centos5:x:1014:
    centos6:x:1015:
    syscent:x:984:
    centos7:x:1016:
    [root@localhost ~]# usermod -c 'also is rhel' centos1
    [root@localhost ~]# tail /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1018:1007:also is rhel:/home/centos1:/bin/bash
    centos2:x:1009:1007::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/home/centos4:/bin/bash
    centos5:x:1012:1014::/home/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# ls /tmp/cent*
    /tmp/centos2:
     
    /tmp/centos3:
    [root@localhost ~]# tail /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1018:1007:also is rhel:/home/centos1:/bin/bash
    centos2:x:1009:1007::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/home/centos4:/bin/bash
    centos5:x:1012:1014::/home/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# usermod -d /tmp/centos4 centos4
    [root@localhost ~]# tail /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1018:1007:also is rhel:/home/centos1:/bin/bash
    centos2:x:1009:1007::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/tmp/centos4:/bin/bash
    centos5:x:1012:1014::/home/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# !ls
    ls /tmp/cent*
    /tmp/centos2:
     
    /tmp/centos3:
    [root@localhost ~]# cd ~centos4
    -bash: cd: /tmp/centos4: 没有那个文件或目录
    [root@localhost ~]# ls -a /home/centos5
    . .. .bash_logout .bash_profile .bashrc .mozilla
    [root@localhost ~]# usermod -md /tmp/centos5 centos5
    [root@localhost ~]# tail /etc/passwd
    suse:x:1006:1006::/home/suse:/bin/bash
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1018:1007:also is rhel:/home/centos1:/bin/bash
    centos2:x:1009:1007::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/tmp/centos4:/bin/bash
    centos5:x:1012:1014::/tmp/centos5:/bin/sh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/etc/csh
    [root@localhost ~]# ls -a /tmp/cent*
    /tmp/centos2:
    . ..
     
    /tmp/centos3:
    . .. .bash_logout .bash_profile .bashrc .mozilla
     
    /tmp/centos5:
    . .. .bash_logout .bash_profile .bashrc .mozilla
    [root@localhost ~]# cd ~centos5
    [root@localhost centos5]# pwd
    /tmp/centos5
    [root@localhost ~]# tail -3 /etc/passwd
    centos7:x:1014:1016::/home/centos7:/etc/csh
    centos6:x:1013:1015::/home/centos6:/bin/zsh
    centos:x:1001:1000::/home/centos:/bin/bash
    [root@localhost ~]# usermod -l CENTOS6 centos6
    [root@localhost ~]# tail -3 /etc/passwd
    centos7:x:1014:1016::/home/centos7:/etc/csh
    centos:x:1001:1000::/home/centos:/bin/bash
    CENTOS6:x:1013:1015::/home/centos6:/bin/zsh
    [root@localhost ~]# usermod -s /bin/bash CENTOS6
    [root@localhost ~]# tail -3 /etc/passwd
    centos7:x:1014:1016::/home/centos7:/etc/csh
    centos:x:1001:1000::/home/centos:/bin/bash
    CENTOS6:x:1013:1015::/home/centos6:/bin/bash
    [root@localhost ~]# tail -3 /etc/shadow
    centos7:$6$PcwwrZ6y$OhQHjDxBQPlMYd6gYasW2119EJlTbnV...iqx8gUhJaBDerqNy4UIrmbvFhDTQrjlWl0yPG/sx1xDUISBpxO0.:17373:0:99999:7:::
    centos:!!:17372:0:99999:7:::
    CENTOS6:!!:17372:0:99999:7:::
    [root@localhost ~]# usermod -L centos7     \centos7的加密密码前面多一个"!"号
    [root@localhost ~]# tail -3 /etc/shadow
    centos7:!$6$PcwwrZ6y$OhQHjDxBQPlMYd6gYasW2119EJlTbnV...iqx8gUhJaBDerqNy4UIrmbvFhDTQrjlWl0yPG/sx1xDUISBpxO0.:17373:0:99999:7:::
    centos:!!:17372:0:99999:7:::
    CENTOS6:!!:17372:0:99999:7:::
    [root@localhost ~]# su - centos1
    上一次登录:三 7月 26 11:45:44 CST 2017pts/3 上
    [centos1@localhost ~]$ pwd
    /home/centos1
    [centos1@localhost ~]$ su - centos7
    密码:
    su: 鉴定故障
    [centos1@localhost ~]$ su - centos7
    密码:
    su: 鉴定故障
    [centos1@localhost ~]$ su - centos7     \\由于centos7的密码被锁定,不能从centos1切到用户centos7
    密码:
    su: 鉴定故障
    [centos1@localhost ~]$ exit
    登出
    [root@localhost ~]# pwd
    /root
    [root@localhost ~]# usermod -U centos7
    [root@localhost ~]# !tail
    tail -5 /etc/shadow
    centos5:!!:17372:0:99999:7:::
    syscent:!!:17372::::::
    centos7:$6$PcwwrZ6y$OhQHjDxBQPlMYd6gYasW2119EJlTbnV...iqx8gUhJaBDerqNy4UIrmbvFhDTQrjlWl0yPG/sx1xDUISBpxO0.:17373:0:99999:7:::
    centos:!!:17372:0:99999:7:::
    CENTOS6:!!:17372:0:99999:7:::
    [root@localhost ~]# su - centos1
    上一次登录:三 7月 26 11:47:13 CST 2017pts/3 上
    [centos1@localhost ~]$ pwd
    /home/centos1
    [centos1@localhost ~]$ su - centos7     \\centos7的密码解锁后,从centos1切到用户centos7
    密码:
    上一次登录:三 7月 26 11:46:11 CST 2017pts/3 上
    最后一次失败的登录:三 7月 26 11:47:52 CST 2017pts/3 上
    最有一次成功登录后有 3 次失败的登录尝试。
    [centos7@localhost ~]$
    [centos7@localhost ~]$
    [centos7@localhost ~]$ pwd
    /home/centos7
    [centos7@localhost ~]$

userdel
  • image.png
  • 命令演示
    [root@localhost ~]# tail /etc/passwd
    rhel:x:1007:1009::/home/rhel:/bin/bash
    centos1:x:1018:1007:also is rhel:/home/centos1:/bin/bash
    centos2:x:1009:1007::/tmp/centos2:/bin/bash
    centos3:x:1010:1012::/tmp/centos3:/bin/bash
    centos4:x:1011:1013::/tmp/centos4:/bin/bash
    centos5:x:1012:1014::/tmp/centos5:/bin/sh
    syscent:x:989:984::/home/syscent:/bin/bash
    centos7:x:1014:1016::/home/centos7:/bin/bash
    centos:x:1001:1000::/home/centos:/bin/bash
    CENTOS6:x:1013:1015::/home/centos6:/bin/bash
    [root@localhost ~]# lls /home
    bash: lls: 未找到命令...
    相似命令是: 'ls'
    [root@localhost ~]# ll /home
    总用量 0
    drwx------. 3 centos centos 78 7月 25 21:56 centos
    drwx------. 5 centos1 redhat 128 7月 26 11:46 centos1
    drwx------. 3 CENTOS6 centos6 78 7月 25 22:26 centos6
    drwx------. 5 centos7 centos7 128 7月 26 11:42 centos7
    drwx------. 3 fedora fedora 78 7月 25 21:56 fedora
    drwx------. 3 rhel rhel 78 7月 25 22:02 rhel
    drwx------. 3 suse suse 78 7月 25 21:57 suse
    [root@localhost ~]# ls /tmp/cen*
    /tmp/centos2:
     
    /tmp/centos3:
     
    /tmp/centos5:
    [root@localhost ~]# ls -d /tmp/cen*
    /tmp/centos2 /tmp/centos3 /tmp/centos5
    [root@localhost ~]# ls -a /tmp/cen*
    /tmp/centos2:
    . ..
     
    /tmp/centos3:
    . .. .bash_logout .bash_profile .bashrc .mozilla
     
    /tmp/centos5:
    . .. .bash_logout .bash_profile .bashrc .mozilla
    [root@localhost ~]# userdel centos6
    userdel:用户“centos6”不存在
    [root@localhost ~]# userdel CENTOS6
    [root@localhost ~]# userdel -r centos7
    [root@localhost ~]# userdel centos3
    [root@localhost ~]# userdel -r centos5
    [root@localhost ~]# ll /home
    总用量 0
    drwx------. 3 centos centos 78 7月 25 21:56 centos
    drwx------. 5 centos1 redhat 128 7月 26 11:46 centos1
    drwx------. 3 1013 centos6 78 7月 25 22:26 centos6
    drwx------. 3 fedora fedora 78 7月 25 21:56 fedora
    drwx------. 3 rhel rhel 78 7月 25 22:02 rhel
    drwx------. 3 suse suse 78 7月 25 21:57 suse
    [root@localhost ~]# ll /tmp/cent*
    /tmp/centos2:
    总用量 0
     
    /tmp/centos3:
    总用量 0
    [root@localhost ~]# ll -d /tmp/cent*
    drwxr-xr-x. 2 root root 6 7月 25 22:05 /tmp/centos2
    drwx------. 3 1010 1012 78 7月 25 22:21 /tmp/centos3
    [root@localhost ~]#
    [root@localhost ~]# userdel -r centos
    userdel:组“centos”没有移除,因为它包含其它成员。
    userdel:/var/spool/mail/centos 并不属于 centos,所以不会删除
    [root@localhost ~]# userdel -r centos1
    userdel:组“centos1”没有移除,因为它不是用户 centos1 的主组
    [root@localhost ~]# userdel -r centos2
    userdel:组“centos2”没有移除,因为它不是用户 centos2 的主组
    userdel:/tmp/centos2 并不属于 centos2,所以不会删除
    [root@localhost ~]# userdel -r centos3
    userdel:用户“centos3”不存在
    [root@localhost ~]# userdel -r centos4
    userdel:未找到 centos4 的主目录“/tmp/centos4”
passwd
  • image.png
  1. -k 选项以上的中文解释偏差较大,本人在网上搜索的解释也多种多样,只好粘出英文原文“ The option -k is used to indicate that the update should only be for expired authentication tokens (passwords)”;大家自会理解吧。
    • 我的一种理解是只用来更新过期的认证令牌,一个账户只有一个paaswd,要么过期了,要么没过期,难道一个账户可以有多个passwd,不同的过期时间?即使是这样,使用该选项又怎么知道到底更新的是那个过期的passwd呢?
    • 我的另一种理解是,在设置用户passwd时,passwd -k USERNAME,这样就设置了用户只有在passwd过期后才能更新自己的passwd,期限内是无法自己通过passwd更改自己的passwd的。但我演示了操作,没有预想的结果。唯一的不同就是,如下的加粗部分
       
      [root@localhost ~]# useradd centos7   \\新增一普通用户
      [root@localhost ~]# tail -1 /etc/passwd   \\密码为空
      centos7:x:1003:1003::/home/centos7:/bin/bash
      [root@localhost ~]# tail -1 /etc/shadow
      centos7:!!:17381:0:99999:7:::
      [root@localhost ~]#
      [root@localhost ~]# passwd -k centos7
      更改用户 centos7 的密码 。
      为 centos7 更改 STRESS 密码。
      (当前)UNIX 密码:
      passwd: 鉴定令牌操作错误
      [root@localhost ~]# passwd -S centos7   \\新建账户,密码为空,默认账户被锁定
      centos7 LK 2017-08-03 0 99999 7 -1 (密码已被锁定。)
      [root@localhost ~]# passwd centos7   \\显设置个passwd
      更改用户 centos7 的密码 。
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [root@localhost ~]# chage -l centos7
      最近一次密码修改时间 :8月 03, 2017
      密码过期时间 :从不
      密码失效时间 :从不
      帐户过期时间 :从不
      两次改变密码之间相距的最小天数 :0
      两次改变密码之间相距的最大天数 :99999
      在密码过期之前警告的天数 :7
      [root@localhost ~]# passwd -x 10 centos7   \\自定义用户passwd过期时间为10天后
      调整用户密码老化数据centos7。
      passwd: 操作成功
      [root@localhost ~]# chage -l centos7   \\passwd密码到8月13日才会过期
      最近一次密码修改时间 :8月 03, 2017
      密码过期时间 :8月 13, 2017
      密码失效时间 :从不
      帐户过期时间 :从不
      两次改变密码之间相距的最小天数 :0
      两次改变密码之间相距的最大天数 :10
      在密码过期之前警告的天数 :7
      [root@localhost ~]#
      [root@localhost ~]# passwd -k centos7   \\选项k
      更改用户 centos7 的密码 。
      为 centos7 更改 STRESS 密码。
      (当前)UNIX 密码:
      新的 密码:
      重新输入新的 密码:
      passwd:过期的身份验证令牌已经成功更新。
      [root@localhost ~]#
      [root@localhost ~]#
      [root@localhost ~]# su - centos2
      上一次登录:日 8月 13 09:00:12 CST 2017pts/1 上
      [centos2@localhost ~]$ su - centos7
      密码:
      [centos7@localhost ~]$ passwd   \\期限内更改密码,依然可以修改
      更改用户 centos7 的密码 。
      为 centos7 更改 STRESS 密码。
      (当前)UNIX 密码:
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [centos7@localhost ~]$
    • 以上两个疑问,可能是自己对选项k的理解有误吧(大家不要被误导,希望看到的可以不吝赐教,留言噢。),但google了,百度了,都没有k的用法示例。没能解决真够郁闷的,整整纠结两个晚上了,没办法只有把我的疑问写出来,以抒心中块垒了!!!现在内心还是一疙瘩。
  • 命令演示
    • 演示之前,先说一下几个天数的计算原则
      • -x DAYS,如days=5,5天后过期,不含命令最后一次修改时间的当天,且都以日为单位计算,以UTC时区记录时间。如密码最新更改为3日,则过完8日后,即到9日00:00:00后,密码就过期了,用户需在下次登录修改密码
      • -n DAYS,如days=2,2天内用户无法自行修改密码,含命令最后一次修改时间的当天,且都以日为单位计算,以UTC时区记录时间。如密码最新更改为3日,则过完2日后,即到5日00:00:00后,用户才能自行修改密码。
      • -w DAYS,如days=2,密码过期前2天开始提醒用户,这个需要和-x的时间一起算,且都以日为单位计算,以UTC时区记录时间。如最大过期设置日期为8日,则此时提醒开始时间为从7日00:00:00开始。
    • 可能有写啰嗦了,简单的时间计算不值一提,可这个困扰了我很久,啰嗦一下,一吐为快。
       
      [root@localhost ~]# useradd centos1
      [root@localhost ~]# tail -1 /etc/passwd
      centos1:x:1004:1004::/home/centos1:/bin/bash
      [root@localhost ~]# tail -1 /etc/shadow
      centos1:!!:17381:0:99999:7:::
      [root@localhost ~]# passwd -S centos1   \\可以看出新增账户没有设置密码,账户默认被锁定
      centos1 LK 2017-08-03 0 99999 7 -1 (密码已被锁定。)
      [root@localhost ~]# chage -l centos1
      最近一次密码修改时间 :8月 03, 2017
      密码过期时间 :从不
      密码失效时间 :从不
      帐户过期时间 :从不
      两次改变密码之间相距的最小天数 :0
      两次改变密码之间相距的最大天数 :99999
      在密码过期之前警告的天数 :7
      [root@localhost ~]# passwd centos1
      更改用户 centos1 的密码 。
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [root@localhost ~]# passwd -S centos1   \\密码最近更新时间以UTC时区记录的
      centos1 PS 2017-08-03 0 99999 7 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# date
      2017年 08月 04日 星期五 06:57:29 CST
      [root@localhost ~]# date -u   
      2017年 08月 03日 星期四 22:57:31 UTC
      [root@localhost ~]# passwd -x 5 centos1
      调整用户密码老化数据centos1。
      passwd: 操作成功
      [root@localhost ~]# chage -l centos1
      最近一次密码修改时间 :8月 03, 2017
      密码过期时间 :8月 08, 2017
      密码失效时间 :从不
      帐户过期时间 :从不
      两次改变密码之间相距的最小天数 :0
      两次改变密码之间相距的最大天数 :5
      在密码过期之前警告的天数 :7
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 0 5 7 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# date -s "170809 07:59:30"
      2017年 08月 09日 星期三 07:59:30 CST
      [root@localhost ~]# date -u
      2017年 08月 08日 星期二 23:59:32 UTC
      [root@localhost ~]# su - centos2
      上一次登录:三 8月 9 07:59:38 CST 2017pts/0 上
      [centos2@localhost ~]$ date -u
      2017年 08月 08日 星期二 23:59:49 UTC
      [centos2@localhost ~]$ su - centos1
      密码:
      警告:您的密码将在 0天后过期
      最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
      最有一次成功登录后有 11 次失败的登录尝试。
      [centos1@localhost ~]$ date -u
      2017年 08月 09日 星期三 00:00:01 UTC
      [centos1@localhost ~]$ exit
      登出
      [centos2@localhost ~]$ su - centos1
      密码:
      [centos2@localhost ~]$ date -u   \\以UTC时间为准,8日过完后进入9日,密码过期
      2017年 08月 09日 星期三 00:00:16 UTC
      [centos2@localhost ~]$ su - centos1
      密码:
      您需要立即更改密码(密码过期)
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      新的 密码:
      无效的密码: 这个密码和原来的相同
      新的 密码:
      重新输入新的 密码:
      上一次登录:三 8月 9 07:59:57 CST 2017pts/0 上
      最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
      最有一次成功登录后有 3 次失败的登录尝试。
      [centos1@localhost ~]$ whoami
      centos1
      [centos1@localhost ~]$ 登出
      [centos2@localhost ~]$ 登出
      [root@localhost ~]#
      [root@localhost ~]# date
      2017年 08月 09日 星期三 08:01:22 CST
      [root@localhost ~]# hwclock -s   \\将系统时间恢复和硬件时间一致
      [root@localhost ~]# date
      2017年 08月 04日 星期五 07:02:03 CST
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-09 0 5 7 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# passwd centos1   \\以当前系统时间更新密码
      更改用户 centos1 的密码 。
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [root@localhost ~]# passwd -n 1 centos1
      调整用户密码老化数据centos1。
      passwd: 操作成功
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 1 5 7 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# date -u
      2017年 08月 03日 星期四 23:04:05 UTC
      [root@localhost ~]# su - centos1   \\切换账户至centos1
      [centos1@localhost ~]$ passwd    \\修改密码
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      您必须等待更长时间以更改密码
      passwd: 鉴定令牌操作错误
      [centos1@localhost ~]$ date -u   \\当前UTC时间为3日,用户无法自行修改密码
      2017年 08月 03日 星期四 23:04:25 UTC
      [centos1@localhost ~]$ 登出
      [root@localhost ~]# date -s 07:59:30   \\手工设置时间,使时间即将到4日(UTC时间)
      2017年 08月 04日 星期五 07:59:30 CST
      [root@localhost ~]# date -u
      2017年 08月 03日 星期四 23:59:32 UTC
      [root@localhost ~]# su - centos1
      [centos1@localhost ~]$ date -u
      2017年 08月 03日 星期四 23:59:43 UTC
      [centos1@localhost ~]$ passwd
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      您必须等待更长时间以更改密码
      ^C
      [centos1@localhost ~]$ date -u   \\时间进入4日,用户可以修改自己的密码
      2017年 08月 04日 星期五 00:00:04 UTC
      [centos1@localhost ~]$ passwd
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [centos1@localhost ~]$ 登出
      [root@localhost ~]# hwclock -s
      [root@localhost ~]# date
      2017年 08月 04日 星期五 07:11:12 CST
      [root@localhost ~]# passwd centos1
      更改用户 centos1 的密码 。
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新
      [root@localhost ~]# passwd -n 2 centos1   \\将最小时间改为2为例
      调整用户密码老化数据centos1。
      passwd: 操作成功
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 2 5 7 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# date -s "170805 7:59:30"
      2017年 08月 05日 星期六 07:59:30 CST
      [root@localhost ~]# date -u
      2017年 08月 04日 星期五 23:59:32 UTC
      [root@localhost ~]# su - centos1
      [centos1@localhost ~]$ date -u
      2017年 08月 04日 星期五 23:59:41 UTC
      [centos1@localhost ~]$ passwd
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      您必须等待更长时间以更改密码
      ^C
      [centos1@localhost ~]$ date -u
      2017年 08月 05日 星期六 00:00:04 UTC
      [centos1@localhost ~]$ passwd
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [centos1@localhost ~]$ 登出
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-05 2 5 7 -1 (密码已设置,使用 SHA512 算法。)
      [centos1@localhost ~]$ passwd
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      您必须等待更长时间以更改密码
      passwd: 鉴定令牌操作错误
      [centos1@localhost ~]$ 登出
      [root@localhost ~]#
      [root@localhost ~]# hwclock -s
      [root@localhost ~]# passwd centos1
      更改用户 centos1 的密码 。
      新的 密码:
      重新输入新的 密码:
      抱歉,密码不匹配。
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 2 5 7 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# passwd -w 2 centos1
      调整用户密码老化数据centos1。
      passwd: 操作成功
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 2 5 2 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# chage -l centos1
      最近一次密码修改时间 :8月 03, 2017
      密码过期时间 :8月 08, 2017
      密码失效时间 :从不
      帐户过期时间 :从不
      两次改变密码之间相距的最小天数 :2
      两次改变密码之间相距的最大天数 :5
      在密码过期之前警告的天数 :2
      [root@localhost ~]# date -s "170807 07:59:30"
      2017年 08月 07日 星期一 07:59:30 CST
      [root@localhost ~]# date -u
      2017年 08月 06日 星期日 23:59:32 UTC
      [root@localhost ~]# su - centos2
      上一次登录:三 8月 9 07:59:38 CST 2017pts/0 上
      [centos2@localhost ~]$ date -u
      2017年 08月 06日 星期日 23:59:43 UTC
      [centos2@localhost ~]$ su - centos1
      密码:
      上一次登录:六 8月 5 08:00:57 CST 2017pts/0 上
      最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
      最有一次成功登录后有 6 次失败的登录尝试。
      [centos1@localhost ~]$ 登出
      [centos2@localhost ~]$ date -u
      2017年 08月 06日 星期日 23:59:58 UTC
      [centos2@localhost ~]$ date -u
      2017年 08月 07日 星期一 00:00:03 UTC
      [centos2@localhost ~]$ su - centos1
      密码:
      [centos2@localhost ~]$ su - centos1   \\8日后过期,则在进入7日就开始提醒用户,7和8日,提前2天开始提醒
      密码:
      警告:您的密码将在 1 天后过期
      上一次登录:一 8月 7 07:59:49 CST 2017pts/0 上
      最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
      最有一次成功登录后有 6 次失败的登录尝试。
      [centos1@localhost ~]$ date -u
      2017年 08月 07日 星期一 00:00:33 UTC
      [centos1@localhost ~]$ 登出
      [root@localhost ~]# hwclock -s
      [root@localhost ~]# date
      2017年 08月 04日 星期五 07:23:28 CST
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 2 5 2 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# chage -l centos1
      最近一次密码修改时间 :8月 03, 2017
      密码过期时间 :8月 08, 2017
      密码失效时间 :从不
      帐户过期时间 :从不
      两次改变密码之间相距的最小天数 :2
      两次改变密码之间相距的最大天数 :5
      在密码过期之前警告的天数 :2
      [root@localhost ~]# tail -1 /etc/shadow
      centos1:$6$zTbGXG.g$X65MSjIPklzRf4P2xbmbiSFAxENr2iij1qC356fiHLNDklOqvoIknSYVDdBr.amcDTR7U8FXMianPvaThWGIQ/:17381:2:5:2:::
      [root@localhost ~]# passwd -e centos1
      正在终止用户 centos1 的密码。
      passwd: 操作成功
      [root@localhost ~]# passwd -S centos1
      centos1 PS 1970-01-01 2 5 2 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# chage -l centos1
      最近一次密码修改时间 :密码必须更改
      密码过期时间 :密码必须更改
      密码失效时间 :密码必须更改
      帐户过期时间 :从不
      两次改变密码之间相距的最小天数 :2
      两次改变密码之间相距的最大天数 :5
      在密码过期之前警告的天数 :2
      [root@localhost ~]# tail -1 /etc/shadow
      centos1:$6$zTbGXG.g$X65MSjIPklzRf4P2xbmbiSFAxENr2iij1qC356fiHLNDklOqvoIknSYVDdBr.amcDTR7U8FXMianPvaThWGIQ/:0:2:5:2:::
      [root@localhost ~]# su - centos2
      上一次登录:五 8月 4 07:25:58 CST 2017pts/0 上
      [centos2@localhost ~]$ su - centos1
      密码:
      您需要立即更改密码(root 强制)
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      新的 密码:
      重新输入新的 密码:
      上一次登录:五 8月 4 07:27:06 CST 2017pts/0 上
      最后一次失败的登录:五 8月 4 07:29:38 CST 2017pts/0 上
      最有一次成功登录后有 7 次失败的登录尝试。
      [centos1@localhost ~]$
      [centos2@localhost ~]$ 登出
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 2 5 2 -1 (密码已设置,使用 SHA512 算法。)
      [root@localhost ~]# passwd -d centos1
      清除用户的密码 centos1。
      passwd: 操作成功
      [root@localhost ~]# tail -1 /etc/shadow   \\密码那以列为空
      centos1::17381:2:5:2:::
      [root@localhost ~]# passwd -S centos1
      centos1 NP 2017-08-03 2 5 2 -1 (密码为空。)
      [root@localhost ~]# passwd centos1
      更改用户 centos1 的密码 。
      新的 密码:
      重新输入新的 密码:
      passwd:所有的身份验证令牌已经成功更新。
      [root@localhost ~]# passwd -l centos1
      锁定用户 centos1 的密码 。
      passwd: 操作成功
      [root@localhost ~]# tail -1 /etc/shadow
      centos1:!!$6$vKejG2c1$kIwCcZAb6It1Tgv2FE5B4jeYFm5B3307vxaTxn92hanfoSn2Q63mYvFaXIgK/.A3mSHwROSUri36Ut1kKXkMv1:17381:2:5:2:::
      [root@localhost ~]# passwd -S centos1
      centos1 LK 2017-08-03 2 5 2 -1 (密码已被锁定。)
      [root@localhost ~]# su - centos2
      上一次登录:五 8月 4 07:34:20 CST 2017pts/1 上
      [centos2@localhost ~]$ su - centos1
      密码:
      su: 鉴定故障
      [centos2@localhost ~]$ 登出
      [root@localhost ~]# su - centos1
      [centos1@localhost ~]$ passwd
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      passwd: 鉴定令牌操作错误
      [centos1@localhost ~]$ 登出
      [root@localhost ~]# passwd -u centos1
      解锁用户 centos1 的密码。
      passwd: 操作成功
      [root@localhost ~]# su - centos1
      [centos1@localhost ~]$ passwd
      更改用户 centos1 的密码 。
      为 centos1 更改 STRESS 密码。
      (当前)UNIX 密码:
      您必须等待更长时间以更改密码
      passwd: 鉴定令牌操作错误
      [centos1@localhost ~]$ 登出
      [root@localhost ~]# echo alwin111 | passwd --stdin centos1
      更改用户 centos1 的密码 。
      passwd:所有的身份验证令牌已经成功更新。
      [root@localhost ~]#
      补充
      passwd -S ,显示用户密码的状态信息,如下;
      [root@localhost ~]# passwd -S centos1
      centos1 PS 2017-08-03 2 5 2 -1 (密码已设置,使用 SHA512 算法。)
      在上面的输出中,第一个字段显示的用户名,第二个字段显示密码状态(PS = 密码设置,LK = 密码锁定,NP = 无密码),第三个字段显示了上次修改密码的时间,后面四个字段分别显示了密码能更改的最小期限和最大期限,警告期限和口令不会失效(-1)
gpasswd&newgrp
  • image.png
  • image.png
  • 命令演示
    [root@localhost ~]# useradd centos1
    [root@localhost ~]# useradd centos2
    [root@localhost ~]# useradd centos3
    [root@localhost ~]# useradd centos4
    [root@localhost ~]# groupadd centos
    [root@localhost ~]# grep centos /etc/passwd /etc/group /etc/gshadow
    /etc/passwd:centos1:x:1000:1000::/home/centos1:/bin/bash
    /etc/passwd:centos2:x:1001:1001::/home/centos2:/bin/bash
    /etc/passwd:centos3:x:1002:1002::/home/centos3:/bin/bash
    /etc/passwd:centos4:x:1003:1003::/home/centos4:/bin/bash
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!::
    [root@localhost ~]# id centos1
    uid=1000(centos1) gid=1000(centos1) 组=1000(centos1)
    [root@localhost ~]# id centos2
    uid=1001(centos2) gid=1001(centos2) 组=1001(centos2)
    [root@localhost ~]# id centos3
    uid=1002(centos3) gid=1002(centos3) 组=1002(centos3)
    [root@localhost ~]# id centos4
    uid=1003(centos4) gid=1003(centos4) 组=1003(centos4)
    [root@localhost ~]# gpasswd -a centos4 centos  \\将centos4加入到组centos
    正在将用户“centos4”加入到“centos”组中
    [root@localhost ~]# id centos4
    uid=1003(centos4) gid=1003(centos4) 组=1003(centos4),1004(centos)
    [root@localhost ~]# grep centos /etc/group /etc/gshadow   \\通过这两个配置文件可以看出cento组的成员中包含centos
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:centos4
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!::centos4
    [root@localhost ~]# gpasswd -M centos2,centos3 centos   \\向组中添加成员列表
    [root@localhost ~]# grep centos /etc/group /etc/gshadow   \--M选项会覆盖掉组中已有的成员
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:centos2,centos3
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!::centos2,centos3
    [root@localhost ~]# id centos4
    uid=1003(centos4) gid=1003(centos4) 组=1003(centos4)
    [root@localhost ~]# id centos2
    uid=1001(centos2) gid=1001(centos2) 组=1001(centos2),1004(centos)
    [root@localhost ~]# id centos3
    uid=1002(centos3) gid=1002(centos3) 组=1002(centos3),1004(centos)
    [root@localhost ~]# gpasswd -a centos4 centos   \\再次通过-a选项将centos4加入到组中
    正在将用户“centos4”加入到“centos”组中
    [root@localhost ~]# id centos4
    uid=1003(centos4) gid=1003(centos4) 组=1003(centos4),1004(centos)
    [root@localhost ~]# grep centos /etc/group /etc/gshadow
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:centos2,centos3,centos4
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!::centos2,centos3,centos4
    [root@localhost ~]# id centos1
    uid=1000(centos1) gid=1000(centos1) 组=1000(centos1)
    [root@localhost ~]# gpasswd -A centos1 centos   \\将centos1用户设置为组管理员,即使其事先不是该组的成员
    [root@localhost ~]# id centos1
    uid=1000(centos1) gid=1000(centos1) 组=1000(centos1)
    [root@localhost ~]# !grep
    grep centos /etc/group /etc/gshadow
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:centos2,centos3,centos4
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!:centos1:centos2,centos3,centos4
    [root@localhost ~]# gpasswd -a centos1 centos   \\将centos1加入到组中
    正在将用户“centos1”加入到“centos”组中
    [root@localhost ~]# id centos1
    uid=1000(centos1) gid=1000(centos1) 组=1000(centos1),1004(centos)
    [root@localhost ~]# !grep
    grep centos /etc/group /etc/gshadow
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:centos2,centos3,centos4,centos1
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!:centos1:centos2,centos3,centos4,centos1
    [root@localhost ~]# gpasswd -d centos4 centos   \\将用户移除出组
    正在将用户“centos4”从“centos”组中删除
    [root@localhost ~]# id centos4
    uid=1003(centos4) gid=1003(centos4) 组=1003(centos4)
    [root@localhost ~]# !grep
    grep centos /etc/group /etc/gshadow
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:centos2,centos3,centos1
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!:centos1:centos2,centos3,centos1
    [root@localhost ~]# su - centos2
    [centos2@localhost ~]$ gpasswd -d centos3 centos   \\centos2没有权限对组操作
    gpasswd:没有权限。
    [centos2@localhost ~]$ 登出
    [root@localhost ~]# su - centos1
    [centos1@localhost ~]$ id centos3
    uid=1002(centos3) gid=1002(centos3) 组=1002(centos3),1004(centos)
    [centos1@localhost ~]$ gpasswd -d centos3 centos   \\通过组管理员centos1来移除用户
    正在将用户“centos3”从“centos”组中删除
    [centos1@localhost ~]$ id centos3
    uid=1002(centos3) gid=1002(centos3) 组=1002(centos3)
    [centos1@localhost ~]$ 登出
    [root@localhost ~]# !grep
    grep centos /etc/group /etc/gshadow
    /etc/group:centos1:x:1000:
    /etc/group:centos2:x:1001:
    /etc/group:centos3:x:1002:
    /etc/group:centos4:x:1003:
    /etc/group:centos:x:1004:centos2,centos1
    /etc/gshadow:centos1:!::
    /etc/gshadow:centos2:!::
    /etc/gshadow:centos3:!::
    /etc/gshadow:centos4:!::
    /etc/gshadow:centos:!:centos1:centos2,centos1
    [root@localhost ~]# su - centos1   \\用centos1登录系统
    [centos1@localhost ~]$ id   \\此时centos为辅助组
    uid=1000(centos1) gid=1000(centos1) 组=1000(centos1),1006(centos) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos1@localhost ~]$ newgrp - centos   \\临时切换到组centos
    [centos1@localhost ~]$ id   \\centos1的主组前后发生了变化,变为centos
    uid=1000(centos1) gid=1006(centos) 组=1006(centos),1000(centos1) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos1@localhost ~]$ 登出
    [centos1@localhost ~]$ 登出
    [root@localhost ~]# su - centos3
    [centos3@localhost ~]$ newgrp - centos   \\centos3不是组中成员,需要密码才能拥有组的权限,而组还未设置密码,所以拒绝用户访问
    密码:
    无效的密码。
    [centos3@localhost ~]$
    [centos3@localhost ~]$ 登出
    [root@localhost ~]# gpasswd centos   \\设置组密码
    正在修改 centos 组的密码
    新密码:
    请重新输入新密码:
    [root@localhost ~]# su - centos1
    [centos1@localhost ~]$ newgrp - centos   \\centos1为组中成员,无需密码即可切换到组centos
    [centos1@localhost ~]$ id
    uid=1000(centos1) gid=1006(centos) 组=1006(centos),1000(centos1) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos1@localhost ~]$ 登出
    [centos1@localhost ~]$ 登出
    [root@localhost ~]# su - centos3   \\用centos3登录系统
    [centos3@localhost ~]$ id
    uid=1002(centos3) gid=1002(centos3) 组=1002(centos3) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos3@localhost ~]$ id centos3
    uid=1002(centos3) gid=1002(centos3) 组=1002(centos3)
    [centos3@localhost ~]$ newgrp - centos   \\输入密码获取组的权限
    密码:
    [centos3@localhost ~]$ id
    uid=1002(centos3) gid=1006(centos) 组=1006(centos),1002(centos3) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos3@localhost ~]$ id centos
    id: centos: no such user
    [centos3@localhost ~]$ id centos3
    uid=1002(centos3) gid=1002(centos3) 组=1002(centos3)
    [centos3@localhost ~]$ 登出
    [centos3@localhost ~]$ 登出
    [root@localhost ~]# su - centos3
    [centos3@localhost ~]$ pwd
    /home/centos3
    [centos3@localhost ~]$ touch du1   \\用户在自己的主组下创建文件,其属组是用户所在的主组
    [centos3@localhost ~]$ ll
    总用量 0
    -rw-rw-r--. 1 centos3 centos3 0 8月 5 16:54 du1
    [centos3@localhost ~]$ newgrp - centos
    密码:
    [centos3@localhost ~]$ id
    uid=1002(centos3) gid=1006(centos) 组=1006(centos),1002(centos3) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos3@localhost ~]$ touch du2   \\获取组权限后,用户在自己的主组下创建文件,其属组是用户所获取的组
    [centos3@localhost ~]$ ll
    总用量 0
    -rw-rw-r--. 1 centos3 centos3 0 8月 5 16:54 du1
    -rw-r--r--. 1 centos3 centos 0 8月 5 16:54 du2
    [root@localhost ~]# grep centos /etc/gshadow
    centos1:!::
    centos2:!::
    centos3:!::
    centos4:!::
    centos:$6$7OdwRIMUo8//v$9SvuMjm7Ixoim3ON97sGEt07I.BhQu/r5.6eWwaqqdnQMN6XUZqJdHXkJki7Z9CAGVvZgr4Eef9frGi9iuteX0:centos1:centos1,centos2
    [root@localhost ~]# gpasswd -r centos   \\清楚组密码,gshadow文件记录密码的一列为空
    [root@localhost ~]# !grep
    grep centos /etc/gshadow
    centos1:!::
    centos2:!::
    centos3:!::
    centos4:!::
    centos::centos1:centos1,centos2
    [root@localhost ~]#

至于-R的命令演示,和man手册上说明的有很大的不同,用-R后,成员依然无需密码就能获取组权限,而非成员组无法通过密码获取组权限,仅仅限制了非成员组的访问,而成员的访问没有起到效果。等待大神帮忙解决了,再进行补充吧
终于找到了原因,原来是系统man手册的介绍错误,我的天哪,还能有这样的错误,弄了一天了,原来是OS的锅。好吧,毕竟man手册也是人写的,如下:看下我系统的关于-R参数的解释图一和别人的解释图二对比


图一
图二

图二才是正解(限制用户登入组,只有组中的成员才可以用newgrp加入改组),赶紧把我之前的错误解释改掉!
和网上搜到的中文解释也是一致的。都怪自己太相信自己系统的解释,中文解释可能会有误差(与英文原文),从没有怀疑自己系统的man手册解释。导致被折磨了整个周六一天。
好了不扯淡了,赶紧补充完命令演示

[root@localhost ~]# gpasswd centos   \\给组设置密码alwinqqq
正在修改 centos 组的密码
新密码:
请重新输入新密码:
[root@localhost ~]# !grep
grep centos /etc/gshadow /etc/group
/etc/gshadow:centos1:!::
/etc/gshadow:centos2:!::
/etc/gshadow:centos3:!::
/etc/gshadow:centos4:!::
/etc/gshadow:centos:$6$s7YXXfFhDh$F8Z05QeuZdBe.ePxf8wz4Qlxs25EK3ohEVniaDt7QwlZDthBcvvcb67/OLy3zCpCYLsObYBU1GDOs9YMFCQen0::centos2
/etc/group:centos1:x:1000:
/etc/group:centos2:x:1001:
/etc/group:centos3:x:1002:
/etc/group:centos4:x:1003:
/etc/group:centos:x:1006:centos2
[root@localhost ~]# su - centos2   \\切换组成员centos2登录系统
上一次登录:六 8月 5 23:08:43 CST 2017从 10.1.18.1pts/2 上
[centos2@localhost ~]$ id
uid=1001(centos2) gid=1001(centos2) 组=1001(centos2),1006(centos) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos2@localhost ~]$ newgrp centos   \\无需密码即可切换主组
[centos2@localhost ~]$ id
uid=1001(centos2) gid=1006(centos) 组=1006(centos),1001(centos2) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos2@localhost ~]$ exit
[centos2@localhost ~]$ 登出
[root@localhost ~]# su - centos1   \\切换非组成员centos2登录系统
上一次登录:六 8月 5 18:14:47 CST 2017pts/0 上
最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
最有一次成功登录后有 6 次失败的登录尝试。
[centos1@localhost ~]$ id
uid=1000(centos1) gid=1000(centos1) 组=1000(centos1) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos1@localhost ~]$ newgrp centos   \\需要密码切换主组
密码:
[centos1@localhost ~]$ id
uid=1000(centos1) gid=1006(centos) 组=1006(centos),1000(centos1) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos1@localhost ~]$ exit
[centos1@localhost ~]$ 登出
[root@localhost ~]#
[root@localhost ~]# gpasswd -R centos   \\R参数限制组外成员访问
[root@localhost ~]# !grep   \\密码处变为叹号
grep centos /etc/gshadow /etc/group
/etc/gshadow:centos1:!::
/etc/gshadow:centos2:!::
/etc/gshadow:centos3:!::
/etc/gshadow:centos4:!::
/etc/gshadow:centos:!::centos2
/etc/group:centos1:x:1000:
/etc/group:centos2:x:1001:
/etc/group:centos3:x:1002:
/etc/group:centos4:x:1003:
/etc/group:centos:x:1006:centos2
[root@localhost ~]# su - centos2
上一次登录:日 8月 6 00:52:12 CST 2017pts/0 上
[centos2@localhost ~]$ id
uid=1001(centos2) gid=1001(centos2) 组=1001(centos2),1006(centos) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos2@localhost ~]$ newgrp centos   \\组成员切换不受影响,前后无变化
[centos2@localhost ~]$ id
uid=1001(centos2) gid=1006(centos) 组=1006(centos),1001(centos2) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos2@localhost ~]$ exit
[centos2@localhost ~]$ 登出
[root@localhost ~]#
[root@localhost ~]# su - centos1
上一次登录:日 8月 6 00:52:36 CST 2017pts/0 上
最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
最有一次成功登录后有 6 次失败的登录尝试。
[centos1@localhost ~]$ id
uid=1000(centos1) gid=1000(centos1) 组=1000(centos1) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos1@localhost ~]$ newgrp centos   \\组外成员无法切换,即时知道密码也无用
密码:
无效的密码。
[centos1@localhost ~]$ 登出
[root@localhost ~]# su - centos3
上一次登录:六 8月 5 16:53:13 CST 2017pts/0 上
[centos3@localhost ~]$ id
uid=1002(centos3) gid=1002(centos3) 组=1002(centos3) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[centos3@localhost ~]$ newgrp centos   \\组外成员无法切换,即时知道密码也无用
密码:
无效的密码。
[centos3@localhost ~]$ 登出
[root@localhost ~]#

最后在啰嗦几句吧,因为被折磨的原因,不吐不快

  • gpasswd组成员管理的功能,可以增加、删除用户、以及设置组管理员;并且可以实现用户主组的临时切换,组内用户无需密码可以实现自由切换,通过newgrp命令切换;若非组中的成员也可通过newgrp切换,此时需要给newgrp设置组密码,非组成员用户通过密码实现临时切换主组;也可以通过R参数限制非组成员登录,即使其知道组的密码,所以此时只有组内成员可以临时切换到改组
id
  • image.png
  • 命令演示
    [root@localhost ~]# grep centos2 /etc/passwd /etc/group
    /etc/passwd:centos2:x:1001:1001::/home/centos2:/bin/bash
    /etc/group:centos2:x:1001:
    /etc/group:centos:x:1006:centos1,centos2
    [root@localhost ~]# id centos2
    uid=1001(centos2) gid=1001(centos2) 组=1001(centos2),1006(centos)
    [root@localhost ~]# id -u centos2
    1001
    [root@localhost ~]# id -g centos2
    1001
    [root@localhost ~]# id -G centos2
    1001 1006
    [root@localhost ~]# id -Gn centos2
    centos2 centos
    [root@localhost ~]# id -gn centos2
    centos2
    [root@localhost ~]# id -un centos2
    centos2
    [root@localhost ~]# su - centos2
    [centos2@localhost ~]$ id
    uid=1001(centos2) gid=1001(centos2) 组=1001(centos2),1006(centos) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos2@localhost ~]$ newgrp - centos
    [centos2@localhost ~]$ id
    uid=1001(centos2) gid=1006(centos) 组=1006(centos),1001(centos2) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [centos2@localhost ~]$ grep centos2 /etc/passwd /etc/group   \\通过newgrp临时切换主组,配置文件里的主组并没有发生改变
    /etc/passwd:centos2:x:1001:1001::/home/centos2:/bin/bash
    /etc/group:centos2:x:1001:
    /etc/group:centos:x:1006:centos1,centos2
    [centos2@localhost ~]$ id -u
    1001
    [centos2@localhost ~]$ id -g   \\主组变成了centos
    1006
    [centos2@localhost ~]$ id -G
    1006 1001
    [centos2@localhost ~]$ id -nG
    centos centos2
    [centos2@localhost ~]$

su
  • image.png
  • 命令演示
    [root@localhost ~]# su - centos1
    上一次登录:六 8月 5 16:33:58 CST 2017pts/0 上
    最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
    最有一次成功登录后有 6 次失败的登录尝试。
    [centos1@localhost ~]$ pwd
    /home/centos1
    [centos1@localhost ~]$ 登出
    [root@localhost ~]# su -l centos1
    上一次登录:六 8月 5 17:57:40 CST 2017pts/0 上
    最后一次失败的登录:三 8月 9 08:00:02 CST 2017pts/0 上
    最有一次成功登录后有 6 次失败的登录尝试。
    [centos1@localhost ~]$ pwd
    /home/centos1
    [centos1@localhost ~]$ 登出
    [root@localhost ~]# su centos1
    [centos1@localhost root]$ pwd
    /root
    [root@localhost ~]# ll xiangjis
    ls: 无法访问xiangjis: 没有那个文件或目录
    [root@localhost ~]# su -c "mkdir xiangjis" centos1
    mkdir: 无法创建目录"xiangjis": 权限不够
    [root@localhost ~]# su -c "mkdir /tmp/xiangjis" centos1
    [root@localhost ~]#[root@localhost ~]#
    drwxr-xr-x. 2 centos1 centos1 6 8月 5 17:59 /tmp/xiangjis
    [root@localhost ~]# date
    2017年 08月 05日 星期六 17:59:28 CST
    [root@localhost ~]#

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,560评论 4 361
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,104评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,297评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,869评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,275评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,563评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,833评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,543评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,245评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,512评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,011评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,359评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,006评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,062评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,825评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,590评论 2 273
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,501评论 2 268

推荐阅读更多精彩内容