sudo is a very useful tool on the Unix/linux platform that allows system administrators to assign some reasonable "rights" to ordinary users to perform tasks that only superuser or other privileged users can accomplish.
For example, a normal user cannot create a user by default, and as the server grows under the production environment, the administrator may authorize some specific
Users create accounts, restart certain services, and so on, Sudo is used here.
Usage example authorizing a normal user to create a user
Create a normal user
[Email protected] ~]# Useradd test
[Email protected] ~]# passwd test
Create an account with a regular user Tom
[Email protected] ~]$ Useradd Tom
-bash:/usr/sbin/useradd: Insufficient Authority
Configure Sudoer
Method 1:vim/etc/sudoers (need to use wq! to force save after configuration)
Method 2:visudo
Edit sudoer Add in tail line
Visudo
Test all= (Root)/usr/sbin/useradd
# # Test User can execute/usr/sbin/useradd with root command Note here Command write absolute path
Create an account with a regular user Tom
[[email protected] ~]$ sudo useradd Tom
[sudo] password for test: # #输入test user's account password
[[email protected] ~]$ ID Tom # #查看
uid=503 (Tom) gid=503 (Tom) group =503 (Tom)
Additional notes:
1: Create Tom successful, you can use sudo useradd to create another user, no longer need to enter the test username password, the default remains 5 minutes.
2: Use Suoer useradd to create a user can not enter the password, you need to add nopasswd in front of/usr/sbin/useradd:
3: Create a user's log can be found under/var/log/secure
This article is from the "10852974" blog, please be sure to keep this source http://10862974.blog.51cto.com/10852974/1770223
Use of the sudo command