Debian7 sudo is invalid

Source: Internet
Author: User

Today, a group of servers added new users. After configuring the sudoers file used by The sudo command, I found that sudo on a server did not take effect. Why did sudo become invalid? The first occurrence occurs as follows:

$ Sudo ifconfig

Sudo: ifconfig: Command not found

$ Sudo fdisk-l

Sudo: fdisk: Command not found

How can I modify the configuration file and restart all servers? sudo does not work for common users. After a while, I finally found that it had something to do with environment variables. The solution is as follows:

1. When a single common user

(1) After logging on to a common user, find the. profile file. Be careful.

$ LS-Al

(2) edit the file. Profile

$ Vim. Profile # Add the following content:

Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Export path

(3) test: $ sudo ifconfig # Show OK

2. If your system has multiple common users

(1) Use the root user

# Vim/etc/profile # Add/sbin to the path variable after else

If ["'id-U'"-EQ 0]; then

Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Else

Path = "/usr/local/bin:/usr/local/games:/usr/games:/sbin"

Fi

Export path

# Source/etc/profile

(3) test. If the remote connection is required, log out and log on again.

### Description:Add/sbin because ifconfig fdisk and other commands are all here!


This article from the "old tile" blog, please be sure to keep this source http://laowafang.blog.51cto.com/251518/1433168

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.