[root@VM_168_102_centos ~]# groupdel user1
groupdel: cannot remove the primary group of user 'user1'
[root@VM_168_102_centos ~]# groupdel wudi
[root@VM_168_102_centos ~]# cat /etc/group | grep "wudi"
[root@VM_168_102_centos ~]#
#passwd命令:设定用户密码 管理员修改自身密码:
[root@VM_168_102_centos ~]# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
管理员修改其他用户密码:
[root@VM_168_102_centos ~]# passwd wanghan
Changing password for user wanghan.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
用户修改自身密码:
[wanghan@VM_168_102_centos rott]$ passwd
Changing password for user wanghan.
Changing password for wanghan.
(current) UNIX password: //输入当前密码
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
passwd –l:锁定用户密码,用户不能修改密码
[root@VM_168_102_centos ~]# passwd -l wanghan
Locking password for user wanghan.
passwd: Success
[root@VM_168_102_centos ~]# su wanghan
[wanghan@VM_168_102_centos rott]$ passwd
Changing password for user wanghan.
Changing password for wanghan.
(current) UNIX password:
passwd: Authentication token manipulation error
passwd –u:解除用户密码锁定
[root@VM_168_102_centos ~]# passwd -u wanghan
Unlocking password for user wanghan.
passwd: Success
[root@VM_168_102_centos ~]# su wanghan
[wanghan@VM_168_102_centos rott]$ passwd
Changing password for user wanghan.
Changing password for wanghan.
(current) UNIX password:
New password:
Last password change : Aug 13, 2014 //最近一次修改密码
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 //用户密码到期前,提前收到警告信息的天数
chage –m:设定密码可更改的最小天数
[root@VM_168_102_centos ~]# chage -m 5 wanghan
[root@VM_168_102_centos ~]# chage -l wanghan
Last password change : Aug 13, 2014
Password expires : Aug 23, 2014
Password inactive : never
Account expires : never
Minimum number of days between password change : 5
chage –M:设定密码有效的最大天数
[root@VM_168_102_centos ~]# chage -M 10 wanghan
[root@VM_168_102_centos ~]# chage -l wanghan
Last password change : Aug 13, 2014
Password expires : Aug 23, 2014
Password inactive : never
Account expires : never
Minimum number of days between password change : 5
Maximum number of days between password change : 10
Number of days of warning before password expires : 7
chage -E:设定帐号的到期日期,0是立即过期,-1永不过期
[root@VM_168_102_centos ~]# chage -E 0 wanghan
[root@VM_168_102_centos ~]# chage -l wanghan
Last password change : Aug 13, 2014
Password expires : Aug 23, 2014
Password inactive : never
Account expires : Jan 01, 1970 //帐号过期日期
[root@VM_168_102_centos ~]# chage -E -1 wanghan
[root@VM_168_102_centos ~]# chage -l wanghan
Last password change : Aug 13, 2014
Password expires : Aug 23, 2014
Password inactive : never
Account expires : never //帐号永不过期
chage –W:设定用户密码到期前,提前收到警告信息的天数
[root@VM_168_102_centos ~]# chage -W 5 wanghan
[root@VM_168_102_centos ~]# chage -l wanghan
Last password change : Aug 13, 2014
Password expires : Aug 23, 2014
Password inactive : never
Account expires : never
Minimum number of days between password change : 5
Maximum number of days between password change : 10
Number of days of warning before password expires : 5
#id命令:显示用户ID及所属群组ID
[root@VM_168_102_centos ~]# id
uid=0(root) gid=500(wanghan) groups=500(wanghan)
[root@VM_168_102_centos ~]# id wanghan
uid=500(wanghan) gid=2008(hp) groups=2008(hp)
id -u:显示用户UID,跟-n一起使用则显示用户名
[root@VM_168_102_centos ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@VM_168_102_centos ~]# id -u
0
[root@VM_168_102_centos ~]# id -u -n
root
id -g:显示基本组ID,跟-n一起使用则显示其基本组名
[root@VM_168_102_centos ~]# id wanghan
uid=500(wanghan) gid=2008(hp) groups=2008(hp)
[root@VM_168_102_centos ~]# id -g wanghan
2008
[root@VM_168_102_centos ~]# id -g -n wanghan
hp
id –G:显示所有组ID,跟-n一起使用则显示所有组名
[root@VM_168_102_centos ~]# id user1
uid=899(user1) gid=899(user1) groups=899(user1),2008(hp)
[root@VM_168_102_centos ~]# id -G user1
899 2008
[root@VM_168_102_centos ~]# id -G -n user1
user1 hp