sudo issues for non-root users under Linux

Source: Internet
Author: User

Linux root user is a super administrator, generally do not use this user login to operate, but sometimes need root permissions, and do not want to switch users can be used sudo command. However, not all users can use the sudo command.

You may first encounter the following prompt:
Xxxis not in the sudoers file. This incident would be reported.

Workaround:

1. Modify the/etc/sudoers file

#su-
#chmod u+w/etc/sudoers
The next line in Root all= (all) is added
Username all= (All) all
#chmod u-w/etc/sudoers

You may also encounter the following prompt
SUDO:XXX: Command not found
This is the path problem, continue with the following operation

2. Add the user to the wheel group

#vi/etc/passwd
Change the user's group number to ten (the Whell group number is 10, this step requires a re-login to take effect)

3. Modify Sudo configuration file/etc/sudoers

#visudo
or direct vi/etc/sudoers.
Defaults env_keep = "COLORS DISPLAY HOSTNAME histsize INPUTRC kdedir
Ls_colors MAIL PS1 PS2 qtdir USERNAME
LANG lc_address lc_ctype lc_collate lc_identification
Lc_measurement lc_messages lc_monetary lc_name lc_numeric
Lc_paper lc_telephone lc_time lc_all LANGUAGE Linguas
_xkb_charset xauthority PATH "
Add path to the Env_keep. (This step requires a re-login to take effect)

4, modify the/etc/profile

# Path Manipulation
#if ["$EUID" = "0"]; then;
Revision changed to
Gid= '/usr/bin/id-g '
If [$gid-eq];then
#source/etc/profile

This solves the problem.

If you do not want the root user to log in remotely, you can do the following:
Modify the configuration file/etc/sshd/sshd_config,
Find Permitrootlogin in the file
"Permitrootlogin No" means that the root user is not allowed to telnet,
"Permitrootlogin yes" means allowing the root user to remotely
Modify to the desired result

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.