Linux xx is not in the sudoers file. This incident will be reported.

  1. Switch to root user
      The method is to directly enter: su on the command line, and then enter the password (that is, your login password, and the password is not visible by default).
  2. The /etc/sudoers file is read-only by default, also for root, so you need to add the write permission of the sudoers file first, the command is:
    That is to perform the operation: chmod u+w /etc/sudoers
  3. Edit the sudoers file
    That is to execute: vi /etc/sudoers
    Find this line root ALL=(ALL) ALL, add xxx ALL=(ALL) ALL below him (where xxx is your username)

ps: Here, you can add any of the following four lines to sudoers
youuser ALL=(ALL) ALL
%youuser ALL=(ALL) ALL
youuser ALL=(ALL) NOPASSWD: ALL
%youuser ALL=(ALL) NOPASSWD: ALL

The first line: Allow the user youuser to execute the sudo command (password required).
The second line: Allow users in the user group youuser to execute the sudo command (password required).
The third line: Allow the user youuser to execute the sudo command without entering a password when executing it.
The fourth line: Allow users in the user group youuser to execute the sudo command without entering a password when executing it.

  1. To revoke the write permission of sudoers file, command:
    chmod u-w /etc/sudoers

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

%d 博主赞过: