I have been trying to use the following in visudo to restrict a user from using the following commands and going into another directory , but this doesn't seem to work myuser ALL=!/home/ubuntu,!/usr/sbin/service,!/usr/bin/apt,!/usr/bin/vi,!/usr/bin/touchI have saved the visudo and changes are well reflected in sudoers. what am i doing wrong in here?
Unable to restrict a user from using certain commands
linux;ubuntu
This is expected behaviour, the sudoers file is only consulted when you run sudo so it denies the user access to the command and gives you the relevant error message.sudo suSorry, user xxxx is not allowed to execute '/bin/su' as root on yyyyy.When the user tries to run the command directly, sudo is not involved so you get the error messages produced by the individual commands failing because the user lacks privilege.You can prevent a user from running a specific file by preceding the file with a bang (!), however you cannot stop a user from copying the file to another location and then running it from there.