Centos 新建用户
- 为什么要新建用户?
因为root的权限太多,不方便多人多角色使用,所以添加一个用户
添加用户
- 新建用户
adduser '用户名'
- 添加用户密码
passwd '用户名'
输入两次,并符合密码规则
授权
- 使sudoers文件有写权限
chmod -v u+w /etc/sudoers
- 修改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