CentOS7 创建用户及分配权限

一、建用户与密码

#建用户
[root@xxCento7One config]# adduser esuser

#为esuser用户赋予密码
[root@xxCento7One home]# passwd esuser
Changing password for user esuser.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

 

二、赋予权限

      这里演示为新用户赋予和root用户相同的权限

[root@xxCento7One ~]# visudo

#执行上述命令后,找到  ## Allow root to run any commands anywhere 部分。
#追加类似这样的内容  “NewUser ALL=(ALL) ALL”,效果如下所示

## Allow root to run any commands anywhere
root ALL=(ALL) ALL        #root这部分是自带的
esuser ALL=(ALL) ALL      #esuser这部分是我新增的

 

      还有人说,在/etc/sudoers文件中,追加“NewUser ALL=(ALL) ALL”这部分内容,也是可以的。但是首先需要为/etc/sudoers文件赋予可写的权限。

chmod 755 /etc/sudoers
或
chmod -v u+w /etc/sudoers

都可以

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值