Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Flags/arguments to sudo on my system aren't working.

peter@Sirius:~$ sudo -h
env: -h: No such file or directory
peter@Sirius:~$ sudo -u postgres
env: -u: No such file or directory

However, executables in sudo's path work fine. My problem is not being removed from the admin group, or having a corrupted /etc/sudoers file. Reinstalling sudo did not fix it, either -- http://askubuntu.com/a/46459/42720

Recently upgraded to 12.04; no other problems with the upgrade.

Any ideas? Thanks

share|improve this question
    
probably, you have some config file that set sudo to a different binary. To see where sudo "points" to, try which sudo –  josinalvo Sep 2 '12 at 0:40
    
Points to /usr/bin/sudo –  Peter Becich Sep 2 '12 at 0:42
    
Cool; alias sudo='sudo env PATH=$PATH'. However, the alias is not in ~/.bashrc, ~/.profile, /root/.bashrc or /root/.profile. Any ideas? –  Peter Becich Sep 2 '12 at 0:50
1  
Found it with find ~/ -size -20k -exec grep -H 'alias sudo.*' {} \;; removed the line and it works. Thanks! –  Peter Becich Sep 2 '12 at 1:45
    
@PeterBecich please post that as answer and mark it as accepted later. –  Lekensteyn Sep 2 '12 at 9:09
show 1 more comment

1 Answer 1

up vote 1 down vote accepted

The problem probably is that the sudo you are running is probably different from the system's sudo.

This is (probably) a user configuration.

FIRST: Check if using /usr/bin/sudo works ok, to test that hipotesis.

IF IT DOES: Then either you are using another binary, or an alias

USING ANOTHER BINARY: Users can make different versions of system binaries to use (usually, they are just scripts). To check for that possibility, run which sudo. This will tell you the location of the sudo you are running. IF it says /usr/bin/sudo, then we exclude this possibility. If something else, that is probably the problem

USING AN ALIAS: an alias is a lightweight way to personalize commands. Instead of writing a binary, you make a small alteration, such as adding an option. This is done in configuration scripts for BASH, the program that reads the commands. To check for that, type alias and see if sudo appears on the list. If it does, then this is probably the problem. Use find ~/ -maxdepth 1 -size -20k -exec grep -H 'alias sudo.*' {} \; to find the file that is setting up the alias (Some common guesses would be: ~/.bashrc ; ~/.bash_profile ; ~/.bash_login and ~/.profile ). If you cant find the file, use find ~/ -size -20k -exec grep -H 'alias sudo.*' {} \; instead, to look at all of your user's files. (this will take a long time)

share|improve this answer
    
Yes, this is what I ended up doing. It was an alias. With the -20k argument it was actually very fast, even though my home directory is large. Thanks –  Peter Becich Sep 7 '12 at 1:40
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.