henry.oswald
henry.oswald

Reputation: 5434

Sudo Path - not finding Node.js

I need to run node on my Ubuntu machine with sudo access. The directory of node is in the sudo path but when trying to run it i get a command not found. I can explicitly call node which does work.

//works
node
>

which node
/root/local/node/bin/node

echo sudo $PATH
sudo /root/local/node/bin:/usr/bin/node:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

sudo node --version
sudo: node: command not found

//explicitly calling it works
sudo node /root/local/node/bin
>

Upvotes: 0

Views: 1335

Answers (1)

Tom Zych
Tom Zych

Reputation: 13576

Um, I don't think there's such a thing as a "sudo path" - your second command there is just echoing "sudo" followed by your regular path. In any case, if you're running things with sudo you really, really should not depend on a path - you should give the explicit pathname for every command and file argument whenever possible, to minimize security risks. If sudo doesn't want to run something, you need to use visudo to add it to /etc/sudoers.

Upvotes: 2

Related Questions