I have line in script which is working, but not working from command line.
echo "User ALL = NOPASSWD: ALL, !/bin/su" | sudo tee -a /etc/sudoers
[user@localhost ~]$ echo "test ALL = NOPASSWD: ALL, !/bin/su" | sudo tee -a /etc/sudoers
bash: !/bin/su": event not found
[user@localhost ~]$
Edit: I am trying to add a sudo user with no permission to su command and sudo user have password less access to root using sudo -i. I was just checking each command in that script, to see how they work in command line.
I found a workaround for this in command line, that I have to use "'!'"/bin/su. So can someone help to explain why this didn't work in command line?