Centos7 创建用户并授权

1. 操作系统

centos 7.8

查看操作系统的版本号

cat /etc/redhat-release

备注:以下的操作是以root用户操作

2. 用户操作

2.1 添加用户

adduser 用户名

2.2 设置/修改密码

passwd 用户名

输入新密码和确认密码即可,提示以下内容则表示成功

passwd: all authentication tokens updated successfully

2.3 授权

  • 查看授权文件的权限
ll /etc/sudoers
-r--r-----. 1 root 4328 Nov 28 2019 /etc/sudoers
  • 增加root用户的写权限
chmod -v u+w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0440 (r--r-----) to 0640 (rw-r-----)
  • 为用户授权
vi /etc/sudoers
# 大约在100行后面,新增一行数据,内容如下
## Allow root to run any commands anywhere
# root ALL=(ALL) ALL
用户名	ALL=(ALL)	ALL
# 修改完毕之后保存

猜你喜欢

转载自blog.csdn.net/HPGANG/article/details/120362309
今日推荐