版权声明: https://blog.csdn.net/qq_41749698/article/details/87899932
添加用户
Usage: useradd [options] LOGIN
添加用户
[root@linux1 ~]# useradd niu
修改密码
[root@linux1 ~]# passwd niu
查看用户信息
[root@linux1 ~]# find / -name '*niu*'
/var/spool/mail/niu
/home/niu
删除用户
[root@linux1 mail]# userdel -rf niu
权限管理
groupadd - create a new group
groupdel - delete a group
chmod - change file mode bits
-R, --recursive
change files and directories recursively
chown - change file owner and group
usermod - modify a user account
-a, --append
Add the user to the supplementary group(s). Use only with the -G option.
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma,
with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g
option.
If the user is currently a member of a group which is not listed, the user will be removed from the group. This
behaviour can be changed via the -a option, which appends the user to the current supplementary group list.
把用户niu加到用户组niugroup中
[root@linux1 sharePack]# usermod -a -G niugroup niu
改变文件属组为 niugroup
[root@linux1 sharePack]# chown :niugroup niu.txt
改变文件权限
[root@linux1 sharePack]# ll
total 4
-rw-r--r--. 1 root niugroup 4 Feb 17 21:28 niu.txt
[root@linux1 sharePack]# chmod 770 niu.txt
[root@linux1 sharePack]# ll
total 4
-rwxrwx---. 1 root niugroup 4 Feb 17 21:28 niu.txt
第1个数字 属主
第2个数字 属组
第3个数字 其他
4 r 1 w 2 x