Not OK Computer
Thursday, January 22, 2009
How to execute a sudo command in a script
The -S option for sudo makes sudo read the password from stdin instead of prompting. So it would look something like:
echo 'password' | sudo -S
thecmd
Another option is to modify
/etc/sudoers
to specify
NOPASSWD
for certain users. Edit
/etc/sudoeres
with
visudo
. Then add the line
username ALL=(ALL) NOPASSWD: ALL
where
username
is the user to set.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment