linux add sudo permission to user

1. Add a user and create a corresponding home directory
useradd -d /usr/home/uuuu -m uuuu Add a directory to uuuu
Maybe at this time, it is found that the useradd command cannot be used, that is the environment variable is not set properly, find it directly /usr/sbin/useradd -d . . . .
The deletion is like this
userdel uuuu
2. Elevate the ordinary permissions of uuuu to sudo permissions, and directly go to /etc/sudoers and add a line as follows:
uuuu ALL=(ALL) NOPASSWD: ALL
During this process, you may encounter A little trouble, for example, the permission of /etc/sudoers is -r--r-----, easy to do,
just chmod 777 /etc/sudoers directly, but this is impossible, because it is a system directory, so I have to Check the properties,
lsattr /etc/sudoers, the display is as follows, it means you can't change it randomly,
----i------------, I am root, and dare to restrict me, we have a way, chattr - i /etc/sudoers, then
chmod 777 /etc/sudoers, okay, modify the file, save it, and finally change the permission back to 0440, otherwise, try it yourself and
see what happens occur.
Also chattr +i /etc/sudoers, don't let others change it easily.


Small note:
Use lsattr /var/spool/cron/root to see that the file has been added with the sia attribute: s---ia------- /var/spool/cron/root,
and then use: chattr -isa / var/spool/cron/root Remove these three attributes, you can modify the file, and successfully remove the malicious task.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326174180&siteId=291194637
Recommended