首先切换为root用户 su root;

然后更改etc/sudoers文件的只读为可读可写可执行。

sudo chmod 777 /etc/sudoers

输入visudo命令即可编辑文件,找到root    ALL=(ALL)    ALL的字段

追加username    ALL=(ALL)     ALL,其中username为你当前需要获得root权限的用户名

5分钟之后密码过期,下次需要重新输入,如果不想如此麻烦,可以用以下方法

username    ALL=(ALL)     NOPASSWD: ALL

保存退出,并恢复/etc/sudoers的访问权限为440

 chmod 440 /etc/sudoers

切换到普通用户,测试用户权限提升功能 

相关文章:

  • 2021-11-04
  • 2021-09-18
  • 2021-09-22
  • 2021-08-14
  • 2021-05-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-24
  • 2021-06-05
  • 2022-02-18
相关资源
相似解决方案