Use of the sudo command

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.