How to use sudo command in Linux system?

  

The sudo command under Linux system is mainly used to allocate system permissions. Using the sudo command can improve the permissions of ordinary users and perform some operations. Here's how to use the sudo command in Linux?

First, the characteristics of sudo:

1, the user specifies authorized management command specified operation on the specified host;

2, based on a detailed record of the user sudo Log information related to the executed command;

3, "Check-in system": Time-sensitive authentication, the user will be required to enter the password to verify the user's identity when the user first executes sudo. After successful, the user will get a There is a fixed lifetime of "tokens"; 5 minutes

Second, how to achieve sudo function?

/etc/sudoers: Authorization files can only be edited by the administrator; but generally do not use vim to edit directly, because syntax errors may occur, so the special editing tool visudo command is generally used to authorize.

/etc/sudoers:

Note: Alias ​​definition: Aliases must use all uppercase characters

Built-in variables: ALL: All users

User_Alias:< Br>

User_Alias ​​NAME = item1, item2, . ..

item:

Username

%groupname

#UID

$#GID

User_Alias ​​(indicating that an already defined alias can be used)

Example: User_Alias ​​ADMIN =CentOS, %lx,#500

means to define the ADMIN alias, with centos user, lx group, UID 500 User

Host_Alias: On which hosts you can run

Host_AliasNAME = item1, item2, . . .

item:

hostname

ip

network

Host_Alias

Example: Host_Alias ​​ALLOWADDR =172.16. 37.10,172.16.0.0/16

means to define the ALLOWADDR alias, with ip of 172.16.17.10, network address of 172.16.0.0/16

Runas_AliasNAME

Runas_AliasNAME = item1, Item2, . . .

Usage is the same as User_Alias

Cmnd_Alias:

Cmnd_AliasNAME = item1, item2, . . .

item:

Commands

Directory (all commands in the directory)

Cmnd_Alias

Example: Cmnd_Alias ​​COMMAND =/usr /sbin/useradd, /usr/sbin/userdel, /usr/sbin

means to define COMMAND aliases, all commands under useradd, userdel, and /usr/sbin

Reverse: Cmnd_AliasPASSWD = /usr/bin/passwd [0-9A-Za-z]*,! /usr/bin/passwd root Previous12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved