用户不在sudoers文件中的解决方法

    1.切换到root用户
    输入su root,然后会提示输入密码,如下:
    [user@localhost ~]$ su root
    密码:
    [user@localhost ~]#

    2.查看/etc/sudoers文件权限,如果只读权限,修改为可写权限
    [root@localhost /]# ls -l /etc/sudoers
    -r--r-----. 1 root root 4002 3月   2 2012 /etc/sudoers
    [root@localhost /]# chmod 777 /etc/sudoers
    [root@localhost /]# ls -l /etc/sudoers

    -rwxrwxrwx. 1 root root 4002 3月   2 2012 /etc/sudoers


    3.编辑/etc/sudoers文件,给用户添加权限
    [root@localhost /]# vim /etc/sudoers
    在文件中找到root ALL=(ALL) ALL,在该行下添加:
    username    ALL=(ALL)     ALL
    说明:格式为(用户名    网络中的主机=(执行命令的目标用户)    执行的命令范围)

    4、保存退出,并恢复/etc/sudoers的访问权限为440
    [root@localhost /]# chmod 440 /etc/sudoers
    [root@localhost /]# ls -l /etc/sudoers
    -r--r-----. 1 root root 4022 3月  19 22:59 /etc/sudoers

    5.切换到普通用户
    [root@localhost /]# su user

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值