Centos 新建用户

Centos 新建用户

  1. 为什么要新建用户?
    因为root的权限太多,不方便多人多角色使用,所以添加一个用户

添加用户

  1. 新建用户
adduser '用户名'
  1. 添加用户密码
passwd '用户名'

输入两次,并符合密码规则

授权

  1. 使sudoers文件有写权限
chmod -v u+w /etc/sudoers
  1. 修改sudoers文件
vim /etc/sudoers

找到Allow root to run any commands anywhere
之后添加一行

'用户名' ALL=(ALL) ALL 

如需新用户使用sudo时不用输密码,把最后一个ALL改为NOPASSWD:ALL即可
3. 收回sudores文件的写权限

chmod -v u-w /etc/sudoers

https://www.linuxidc.com/Linux/2016-11/137549.htm

原文地址:https://www.cnblogs.com/ants_double/p/10808911.html