Home  >  Article  >  Operation and Maintenance  >  How to solve the problem of lack of permission after adding an account in Linux?

How to solve the problem of lack of permission after adding an account in Linux?

零下一度
零下一度Original
2017-06-23 11:20:222247browse

After adding a new account, we may find that the new account will report that it is not in sudoers when sudoing, and the authentication will fail after entering the password when using su -s

Most online searches require modification of the contents in /etc/sudoers, but modifying this file requires permissions, which leads to an infinite loop, so we need to change the strategy to change the file in a roundabout way:

1. Use another account with root permissions to log in, and then sudo -s to enter root mode

2. Check the /etc/sudoers file permissions. If the permissions are read-only, change them to write permissions

##3. Modify the /etc/sudoers file and execute the following command:

/*username is your username*/

[root@localhost ~]# echo 'username ALL=(ALL) ALL' >> /etc/sudoers

Or enter Visudo or vim /etc/sudoers with root permissions , find the field of root ALL=(ALL) ALL, append in the next line:

username ALL=(ALL) ALL

##For example, at this time You need to grant permissions to stu2:

##Then esc->:->wq save and exit

4. Restore the access rights of /etc/sudoers to 440

5, and then Log in to the new account to enter root

Note: If the authentication still fails, the only way to change it is to enter recovery mode:

Restart the computer, keep pressing the esc key, enter recovery mode, select root, press Enter, this will enter the root directory

    In Root terminal input mount -o remount rw /
  1. and then chmod 777 /etc/sudoers
  2. nano /etc/sudoers Enter, then add %admin ALL=(ALL) ALL Enter sudo ALL=(ALL:ALL) ALL Save
  3. Enter chmod 440 /etc/sudoers and press Enter
  4. Enter reboot

The above is the detailed content of How to solve the problem of lack of permission after adding an account in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn