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.

Okay, so I have my scripts in ~/bin/, and they are added to the path normally. However, when I prefix them with sudo, they are not in the path. I figure this is because they're not in the path for root which sudo is using.

How can I change it so sudo also looks in my path? Or alternatively, so that my bin is in the root path? Thanks!

share|improve this question
    
it can be a security flaw tho, as a non root user can remove or edit such scripts (such user can be someone else with your normal user or "anyone" without your password in the same group with write access to your script files); my suggestion is to create them at /MyScripts, make it and all the scripts there like: root:root rw-r--r--; another problem I just thought is if you have them synched with a remote storage and it gets changed there and downloaded to your local machine. –  Aquarius Power Jun 21 at 19:53
add comment

1 Answer 1

Open a terminal:

sudo visudo

Edit the line like so (and change wojox to your user):

Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/wojox/bin"
share|improve this answer
    
I removed the extra colon after the user's bin entry in path, as this actually meant that the current working directory was in path as well, and this you do not want. –  user76204 Aug 17 '13 at 17:04
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.