Linux 添加用户、删除用户、创建用户组、用户、用户组授权

添加用户
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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值