Skip to content

Instantly share code, notes, and snippets.

@livealive7
livealive7 / modify_sudoers_for_requiretty.sh
Created August 12, 2021 01:44 — forked from buchireddy/modify_sudoers_for_requiretty.sh
Shell script to modify the /etc/sudoers file and give sudo permissions for a user and also to turn requiretty off.
# 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.
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
devpkey.h
Abstract: