This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Take a backup of sudoers file and change the backup file. | |
sudo cp /etc/sudoers /tmp/sudoers.bak | |
sudo echo "$USER ALL=(ALL) NOPASSWD:ALL | |
Defaults:$USER !requiretty | |
" >> /tmp/sudoers.bak | |
# Check syntax of the backup file to make sure it is correct. | |
sudo visudo -cf /tmp/sudoers.bak | |
if [ $? -eq 0 ]; then | |
# Replace the sudoers file with the new only if syntax is correct. |