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

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


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

猜你喜欢

转载自cakin24.iteye.com/blog/2392258