用户和用户组的基本管理命令

一 实战
[[email protected] ~]# groupadd sexy
[[email protected] ~]# groupmod -n market sexy
[[email protected] ~]# groupmod -g 668 market
[[email protected] ~]# groupadd -g 888 boss
[[email protected] ~]# groupdel market
[[email protected] ~]# groupadd sexy
[[email protected] ~]# useradd -g sexy sdf
[[email protected] ~]# useradd -g sexy jzmb
[[email protected] ~]# useradd -d /home/xxx test
[[email protected] ~]# cat /etc/passwd
[[email protected] ~]# usermod -c dgdzmx sdf
[[email protected] ~]# usermod -l cls sdf
[[email protected] ~]# usermod -d /home/cls cls
[[email protected] ~]# usermod -g sexy test
[[email protected] ~]# userdel jzmb
[[email protected] ~]# touch /etc/nologin
[[email protected] ~]# passwd -ls cls
passwd: bad argument -ls: unknown option
[[email protected] ~]# passwd -l cls
Locking password for user cls.
passwd: Success
[[email protected] ~]# passwd -u cls
Unlocking password for user cls.
passwd: Warning: unlocked password would be empty.
passwd: Unsafe operation (use -f to force)
[[email protected] ~]# passwd -d cls
Removing password for user cls.
passwd: Success
 
二 主要组合附属组

用户和用户组的基本管理命令
 
 
三 实战
[[email protected] ~]# gpasswd -a cls boss
Adding user cls to group boss
[[email protected] ~]# newgrp boss
[[email protected] ~]# gpasswd -d cls boss
Removing user cls from group boss
[[email protected] ~]# useradd -g group1 -G group2
[[email protected] ~]# gpasswd test
Changing the password for group test
New Password:
Re-enter new password:
 
四 其他管理命令
[[email protected] ~]# su cakin24
[[email protected] root]$ su root
Password:
[[email protected] ~]# whoami
root
[[email protected] ~]# id root
uid=0(root) gid=0(root) groups=0(root)
[[email protected] ~]# id cakin24
uid=1000(cakin24) gid=1000(cakin24) groups=1000(cakin24)
[[email protected] ~]# chfn cakin24
Changing finger information for cakin24.
Name [cakin24]: cakin24
Office []: cakin
Office Phone []: cakin
Home Phone []: cakin
 
Finger information changed.