Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure linux sudo permissions

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares with you is about how to configure linux sudo permissions. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Record the simple sudo configuration process of linux and check it later.

1. Root, open the sudo configuration file

[root@centos ~] # visudo

2. Sudo configuration items

# # Next comes the main part: which users can run what software on

# # which machines (the sudoers file can be shared between multiple

# # systems).

# # Syntax:

# #

# # user MACHINE=COMMANDS

# #

# # The COMMANDS section may have other options added to it.

# #

# # Allow root to run any commands anywhere

Root ALL= (ALL) ALL

Mysql ALL= (ALL) ALL # configure all commands executed by the mysql user equivalent to the root user

3. Configure mysql secret-free execution

# # Read drop-in files from / etc/sudoers.d (the # here does not mean a comment)

# includedir / etc/sudoers.d

Mysql localhost= (root) NOPASSWD:ALL

4. Root changes the password of mysql

[root@centos ~] # passwd mysql

5. Mysql adds the sudo password of the mysql user. The sudo password is the password of the mysql operating system layer set in part 4.

-bash-4.1$ sudo uname

[sudo] password for mysql:

Linux

-bash-4.1 $

6. View sudo configuration

[root@centos ~] # sudo-l

Matching Defaults entries for root on this host:

Requiretty,! visiblepw, always_set_home, env_reset, env_keep= "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"

Env_keep+= "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+= "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT

LC_MESSAGES ", env_keep+=" LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE ", env_keep+=" LC_TIME LC_ALL LANGUAGE LINGUAS

_ XKB_CHARSET XAUTHORITY ", secure_path=/sbin\: / bin\: / usr/sbin\: / usr/bin

User root may run the following commands on this host:

(ALL) ALL

[root@centos ~] #

7. Mysql users test whether sudo is correct

-bash-4.1$ sudo mkdir / test1

-bash-4.1$ ls-l / test1

Total 0

-bash-4.1$ rm-rf / test1

Rm: cannot remove `/ test1': Permission denied

-bash-4.1$ sudo rm-rf / test1

-bash-4.1$ ls-l / test1

Ls: cannot access / test1: No such file or directory

-bash-4.1 $

The sudo configuration of linux is complete!

The above is how to configure linux sudo permissions, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report