1

On Ubuntu 12.04, when I do

sudo -u <user> ls

I get

env: -u: No such file or directory

This happens for any command and any user for <user>, including myself and root.

Any ideas how to troubleshoot this?

4
  • 1
    Show which sudo and sudo -l as your user, please
    – dawud
    May 25 '13 at 20:12
  • 1
    it looks like sudo does not recognize "-u" as a flag and tries to run a command named "-u".
    – Petter H
    May 25 '13 at 20:17
  • Ah that was it. which sudo was /usr/bin/sudo, but @PetterH's comment clued me in to the fact there might be an alias set up for sudo. Sure enough...
    – lambinator
    May 25 '13 at 20:23
  • yep, I forgot type sudo
    – dawud
    May 25 '13 at 21:16
4

Turns out sudo was actually running an alias:

$ alias sudo
alias sudo='sudo env PATH=$PATH'

Running /usr/bin/sudo directly skipped the alias and resolved the problem.

Alternatively, you can open the .bashrc file in your home directory and comment out the line:

alias sudo='sudo env PATH=$PATH'

Run source .bashrc again, and (for good measure), run unalias sudo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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