In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to understand sudo commands in Linux". In daily operation, I believe many people have doubts about how to understand sudo commands in Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to understand sudo commands in Linux". Next, please follow the editor to study!
Sudo is a command that allows a specific group of users to run a command with the privileges of another user (typically root). Sudo has detailed logging capabilities and provides fine-grained control over which commands users can run through sudo.
Sudo vs. Su
The su command also provides the same privilege escalation function, but the difference is the granularity of their authentication process and privilege changes. Su allows you to switch from your login session to another user's session, and then you can run any program with that user's privileges, but you need to know the target user's password to switch that user. Sudo, on the other hand, works on a single command basis, allowing you to run a single command with the privileges of root. With sudo you don't have to know the root password, but enter your password when prompted for the sudo password.
Add users to the Sudoers list
As a new user, if you try to run the sudo command, you will encounter the following error. It means that you are not in the sudoers list of such a user group that can be authenticated to use sudo privileges.
The code is as follows:
[my-user-id] is not in the sudoers file. This incident will be reported.
There are two ways to add you to the sudoers list.
Method one
The first way is to add you to the Linux user group called sudo. This particular Linux user group is preconfigured to use sudo. So, once you are in this group, you can run the sudo command.
The following command will add you to Linux's sudo group, which you need to run under the root user.
The code is as follows:
# adduser sudo
Now to confirm that your team membership has been updated, use the groups command to see which group you currently belong to. This list must contain sudo groups.
The code is as follows:
$groups
Alice adm cdrom sudo dip plugdev fuse lpadmin netdev sambashare davfs2 libvirtd docker promiscuous
The change in team membership (and sudo access) will take effect after you log out and log back in.
Method two
The second way to use sudo is to add yourself directly to the / etc/sudoers configuration file.
To modify the / etc/sudoers file, you can use a special sudo editor command called visudo. Simply invoke the following command with your root identity.
The code is as follows:
# visudo
This command opens and edits the / etc/sudoers file, adds the following line to the end of the file, and presses Ctrl+X. When prompted, save the changes and exit.
The code is as follows:
ALL= (ALL) ALL
This change will take effect immediately, and you can use sudo right away.
At this point, the study on "how to understand sudo commands in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.