System Administration & Network Administration
ubuntu php bash sudo
Updated Fri, 20 May 2022 01:02:54 GMT

running bash script as root with hardcoded password

Most probably this has already been answered in other threads, but I can't find the exact solution.

I need to call a bash script via a php script which (bash) changes system time. I need to run that bash script as root while not changing apache permissions, i.e. php script called by user 'nobody' and the php script runs the script as root (sudoing is ok as I'm on ubuntu). As that will be called from a browser, I need to get rid of the password prompt



$ visudo
nobody ALL = NOPASSWD: /path/to/

Which will allow user "nobody" to run the as any user without password prompt.

Comments (1)

  • +2 – And don't forget to make the script owned by root, and writable only by root. — Oct 23, 2009 at 11:14