centos7添加用户并授权 run any commands anywhere

添加用户 demo

[root@localhost ~]# useradd demo
[root@localhost ~]# 

设置用户 demo 密码

[root@localhost ~]# passwd demo

查看权限

[root@localhost ~]# ll /etc/sudoers
-r--r-----. 1 root root 4328 11月 28 2019 /etc/sudoers
[root@localhost ~]# 

添加  /etc/sudoers 写权限

[root@localhost ~]# chmod u+w /etc/sudoers

查看 /etc/sudoers 权限

[root@localhost ~]# ll /etc/sudoers
-rw-r-----. 1 root root 4328 11月 28 2019 /etc/sudoers
[root@localhost ~]# 

编辑 /etc/sudoers,

在root    ALL=(ALL)     ALL 下面一行添加 demo 用户

[root@localhost ~]# vim /etc/sudoers

## Allow root to run any commands anywhere 
root    ALL=(ALL)     ALL
demo ALL=(ALL)       ALL

[root@localhost ~]# 

恢复  /etc/sudoers 文件初始权限

[root@localhost ~]# chmod u-w /etc/sudoers

切换 demo 用户

[root@localhost ~]# su demo

— —

待续……

创作辛苦!

您的每一个赞就是我努力的前进动力!

更多精彩,请关注本博主!

猜你喜欢

转载自blog.csdn.net/frdevolcqzyxynjds/article/details/107247988