The future of you, waiting for you in the future.

Geoffrey

Long, long the pathway to Cold Hill;
Drear, drear the waterside so chill.

返回顶部

Centos7 添加用户及设置权限

一、添加用户

  • 1、登录root 用户

[gau@localhost /]$ su
Password:   # 输入密码
[root@localhost /]# 
  • 2、添加用户
[root@localhost /]# useradd testuser
[root@localhost /]#
  • 3、设置用户密码
[root@localhost /]# passwd testuser
Changing password for user testuser.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost /]#

二、给该用户添加root权限

  • 1、切换到root(#su)

  • 2、#chmod -v u+w /etc/sudoers 为sudoers添加可写权限

  • 3、输入vi sudoers,进入命令模式,按Insert,进入编辑模式

  • 4、在 sudoers 文件添加新用户信息到 ## Allow root to run any commands anywhere 下,修改后的效果为

## Allow root to run any commands anywher
      root   ALL=(ALL)    ALL
      xxx    ALL=(ALL)    ALL #xxx为新增用户

  • 5、保存:按Esc 后 输入 :wq 保存并退出

  • 6、取消 sudoers 文件可写权限     # chmod -v u-w /etc/sudoers

三、测试

1、普通用户进入

2、#sudo mkdir test(创建的文件夹名)

3、#ls 查看目录

4、#sudo rm -r test ( 删除文件夹)
————————————————
版权声明:本文为CSDN博主「喜欢海呀」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_25046261/article/details/78182536

posted @ 2020-01-28 15:43  Geoffreygau  阅读(25545)  评论(2编辑  收藏  举报