Sudo is a very useful tool on the Unix/linux platform that allows system administrators to assign a reasonable "power" to ordinary users to perform tasks that only superuser or other privileged users can accomplish (mainly as commands), such as running some like Mount,halt, Commands such as Su,useradd, Userdel, or edit some system configuration files, such as/etc/mtab,/etc/samba/smb.conf, etc. This has not only reduced the number of logins and administrative time of the root user, but also improved the security of the system.
If you do not give an ordinary user a right, even with the sudo command before using the command, it still does not work.
[Email protected] ~]$ useradd XX
-bash:/usr/sbin/useradd: Insufficient Authority
[[email protected] ~]$ sudo useradd xx
We Trust you are received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) with great power comes great responsibility.
[sudo] password for book:
Book isn't in the sudoers file. This incident would be reported.
[Email protected] book]# vim/etc/sudoers
Method of distribution of rights:
The distribution of power is mainly by adding a line of information in the configuration file/etc/sudoers in the agreed format. (Configure the file to be configured as root)
User Name Host name = (run user name) command to run
Example 1. Book all= (All)/usr/sbin/useradd//Assume that there is a user in the system, giving useradd rights to it
Example 2. Book all= (All) NOPASSWD:/usr/sbin/useradd//No password Authentication required
After switching to book user, execute sudo useradd xx//ordinary user book can add a user xx