Linux uses sudo to enable common user permissions

Source: Internet
Author: User
In linux, I used sudo to open general user permissions to sort out what I wrote earlier. I just forgot about it ~ Others what I have learned is that if you do not use sudo in linux
Sort out the previously written stuff and forget it again just now ~
Bytes ----------------------------------------------------------------------------------------------------------------
I found that I would soon forget what I learned if I didn't summarize it myself or review it. Writing a technical blog not only helps others, but also helps yourself. No matter how simple the problem is, record summary is a habit.

1. generally, sudo is installed in linux. for the redhat series, run the rpm-qi sudo command to view details.

2. switch to root and modify the configuration file/etc/sudoers.
2.1 The configuration file can be configured in either of the following ways:
First: use vi or vim
Vi/etc/sudoers or vim/etc/sudoers
The following is the file content:


 
Method 2: Use the mongodo command
Note: both methods are used to modify the/etc/sudoers file. the values do and vi/etc/sudoers are equivalent. vim/etc/sudoers has syntax highlighting. This is just the difference in using the editor.
(I tried ubuntu and modified/etc/sudoers. tmp by using cmddo)
3. find any line (comments starting with # are recommended to be written under the root line without comments before root) and add the code:
Kehr ALL = (ALL) ALL
Explanations:
Kehr is your username
ALL = (ALL): the first ALL is to restrict the user's login mode (remote, or local), ALL is to accept ALL login methods; the second (ALL) is a command that limits the user's use. ALL indicates that the user can use ALL commands. you can use this option to restrict the commands used by the user, such as ALL =/usr/sbin, the user can only use the command in the/usr/sbin Directory, ALL =/sbin/fdisk, then the user can only use the fdisk Command;
ALL: The Third ALL is not clear at present.

After modification, run the following command:


 
4. in addition to setting users, you can also set user groups. after setting, all users in the user group have the permission to execute specified commands.
Assume that we have a user group manager.
% Manager ALL = (ALL) ALL
Note: add % before the manager to indicate that this is a user group rather than a user. other options are the same as user settings.
5. the above settings can basically achieve the desired effect, but whenever you use the sudo + command, you will be prompted to enter the current user password, if you find it troublesome, you can set it in the configuration file as follows:
Kehr ALL = (ALL) NOPASSWD: ALL
Add NOPASSWD before the last ALL: you can ignore the password when using sudo (the second figure is actually done)
(Suggestion: we do not recommend that you copy and copy all file configurations. you can repeat the configurations to avoid text format issues)

We also recommend a good linux Learning Website: LinuxCast.net.

If you find that the method in this article is insufficient, you can leave a message and I will reply in time.
Related Article

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.