Linux Common Commands--sudo

Source: Internet
Author: User

sudo 以另一个用户身份执行命令

Syntax format: sudo "option" sudo [options]
Note: There must be at least one space between each element in the sudo command and subsequent options and files
Parameter options:-L, which lists the commands that the current user can execute. This option is available only to users in the Sudoers file
Alias types in sudo authorization

User or group Host user roles that can be toggled Command
Root All= (All) All
User_alias ADMIN = Jsmith,mikem,%groupname Host_alias fileservers = FS1,FS2 Runas_alias OP = root Cmnd_alias SERVICES =/sbin/service,/usr/sbin/useradd

sudo configuration considerations

ordinal content
1 command alias member must be a file or the absolute path of the directory
2 alias names are uppercase letters, numbers, underscores, and if letters are uppercase
3 An alias has more than one member, separated by a half-angle "," between members, and the member must be a valid actual existence
4 alias member is alias type Host_alia S, User_alias, Runas_alias, cmnd_alias constraints, define what type of alias, what type of member to match
5 alias rule is one rule per line, if an alias When a rule line is not available, you can continue with "\"
6 Specifies that the user to switch is enclosed in parentheses. If the parentheses are omitted, the default is the root user; if all is in parentheses, the delegate can switch to all users
7 If you do not need a password to run the command directly, you should add nopasswd: Parameters
8 prohibit a class of programs or names from being executed, precede the command action with a "!" number, and place it behind the command that is allowed to execute
9 users Must precede the group with the% number

Note: Licensing all in the exclusion of the sometimes let us not to guard against, this first-off strategy is not a good strategy.
Case one:
Parameter-s Example

Case TWO:
Configuring the sudo command user behavior log audit

Note: The sudo command log audit does not log ordinary users ' normal operations, but rather records the actions of those who perform the sudo command.
Case THREE:
User Management Right sudo configuration simple example



Su and sudo user role switching schematic diagram

sudo working principle flowchart

Linux Common Commands--sudo

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.