Why is sudo bash needed?

On Ubuntu 14.04, a cron job is running a bash script that has to include sudo commands. VISUDO was properly edited to allow ALL=(ALL) NOPASSWD. However, the script keeps failing due to lack of sudo permission. How can that be fixed?

  • Answer:

    If must be run as root, and you have already privileges to edit the sudoers file (so you probably have already root access), why not put that job as root/system cron job? If anyway you want to put it in your user crontab, checked running the process manually as that user? It runs without asking password?

Gustavo Muslera at Quora Visit the source

Was this solution helpful to you?

Other answers

If it is a modern system, like Ubuntu 14 is, you can try running the following pkexec visudo

Jarvis Jones

I like Gustavo's Answer.  However if you want to run as a user, be sure to put fully qualified paths for all commands as cron does not inherit a User's environment.  Also, it might be helpful to see the actual sudoers file entry.  If you did not specify "all" without a password then you may have restricted the permissions too much. Also I don't know if you have SELinux enabled.  You might want to disable it and relable the disk to see if this has any effect.  You might have to tweak SELinux permissions if it is enabled.

Dave Ruedeman

Thank you all for your time and good suggestions.

Shay Ginsbourg

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.