visudo says that there is a syntax error
Solution 1:
I also get the syntax error when I run it on my system. I have done the following:
At the top of the sudoers file (under the "defaults" lines), add the following line (your command you want to run without password):
Cmnd_Alias TAR_COMMAND = /usr/bin/tar -czf /root/assignment/result/student-submissions-*.tar.gz /root/assignment/report/main/
The wildcard * I used in the file name, is there to ensure the command may vary when it comes to the tar.gz filename. This way you don't have to use date variables.
Now add the following line at the end:
manager ALL= NOPASSWD: TAR_COMMAND
Try if that works for you
PS: Always use the full path to your executable. When only using "tar", every binary called "tar" can run from any folder without password. use the full path to ensure you only are able to run /usr/bin/tar.