How to fix ‘sudo: no tty present and no askpass program specified’ error?

Granting the user to use that command without prompting for password should resolve the problem. First open a shell console and type: sudo visudo Then edit that file to add to the very end: username ALL = NOPASSWD: /fullpath/to/command, /fullpath/to/othercommand eg john ALL = NOPASSWD: /sbin/poweroff, /sbin/start, /sbin/stop will allow user john to sudo poweroff, … Read more

How do I use sudo to redirect output to a location I don’t have permission to write to? [closed]

Your command does not work because the redirection is performed by your shell which does not have the permission to write to /root/test.out. The redirection of the output is not performed by sudo. There are multiple solutions: Run a shell with sudo and give the command to it by using the -c option: sudo sh … Read more