sudo -u fails with env: -u: No such file or directory

Posted on

sudo -u fails with env: -u: No such file or directory – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, ubuntu, sudo, , .

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?

Solution :

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.

Leave a Reply

Your email address will not be published. Required fields are marked *