Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I will try to explain my situation first. I am currently running 6 virtualized Debian servers on a ESXi host machine. The virtual servers where installed with a Debian Linux 6 (Lenny).

Recently I updated the servers to debian Wheezy

root@ares> lsb_release -a                                                                                                    /home/vincent
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 7.1 (wheezy)
Release:        7.1
Codename:       wheezy

it has come to my attention that since this upgrade the 'sudo' command is displaying weird behaviour. Actually, it seems to have no effect at all. I checked the /etc/visudo file and everything seems ok. Sudo also asks for my password but then does not seem to run things as root. An example is the 'ifconfig' command:

user@ares> ifconfig 
zsh: command not found: ifconfig
[127] user@ares> sudo ifconfig
sudo: ifconfig: command not found
[1] user@ares> sudo su
root@ares>ifconfig  
output shows    

anyone who can help me out here?

share|improve this question
    
Check your PATH. –  Michael Hampton Aug 2 '13 at 6:37
    
@MichaelHampton thx. This seems to be the issue. Could you post this as answer? Mystery tough how my path has changed after the upgrade... –  Goez Aug 2 '13 at 6:41
add comment

2 Answers

up vote 4 down vote accepted

Your PATH probably differs between your normal user and the root user, likely missing directories such as /sbin and/or /usr/sbin where administrative utilities like ifconfig normally live.

share|improve this answer
add comment

Michael's answer is correct, but I wanted to add a comment:

It is not mandatory to add administrative commands' path (/sbin, /usr/sbin, /usr/local/sbin) to an unprivileged user, as long as the secure_path directive is configured in /etc/sudoers on in your LDAP server, if you use an LDAP backend:

$ ip a s
-rbash: ip: command not found

$ sudo ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000
    link/ether 00:0c:29:57:80:d9 brd ff:ff:ff:ff:ff:ff
    inet 172.22.197.38/24 brd 172.22.197.255 scope global eth0

$ echo $PATH
/home/dawud/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin

$ sudo -l | awk '$0~/secure_path/ {print $1}'
secure_path=/bin\:/usr/bin\:/sbin\:/usr/sbin\:/usr/local/bin\:/usr/local/sbin

Check man sudoers(5) for further reference on secure_path (also of interest are exempt_group and env_reset).

 secure_path   Path used for every command run from sudo.  If you don’t trust the people running sudo to have a sane PATH environment variable you may want to use this.  Another use is if you want to
               have the “root path” be separate from the “user path”.  Users in the group specified by the exempt_group option are not affected by secure_path.  This option is not set by default.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.