Linux用户获得超级管理员权限

问题描述

在创建了新的虚拟机和用户后,用户可能还没有超级管理员的操作权限:

[peng@localhost network-scripts]$ sudo su
[sudo] password for peng: 
peng is not in the sudoers file.  This incident will be reported.

解决方法:

  1. 使用su切换到root用户,会需要root的密码:

    [peng@localhost network-scripts]$ su 
    Password: 
    [root@localhost network-scripts]# 
  2. 然后编辑sudoers文件nano /etc/sudoers,找到下面的一行:

    
    ## Allow root to run any commands anywhere
    
    root    ALL=(ALL)   ALL
  3. 增加新的用户名即可,我这里新用户为peng,后面ALL=(ALL) ALL照写

    
    ## Allow root to run any commands anywhere
    
    root    ALL=(ALL)   ALL
    peng    ALL=(ALL)   ALL
  4. 保存退出

一些用户相关常用的操作

  • adduser [用户名] : 新增用户
  • passwd [用户名] : 修改用户密码
  • userdel -r [用户名]: 删除用户

你可能感兴趣的:(linux,权限,linux)