Skip to end of metadata
Go to start of metadata

You usually need to put password to run commands in sudo. You don't need to put user password if your account belongs to sudoers even though that is not that safer in terms of security point's of view.

Add user ("centos") to sudoers

sudo usermod -aG wheel centos

Note that you can replace your own account instead of centos


Allow sudoers to run commands with no additional password for authenticatoin

sudo sed -i 's/# %wheel        ALL=(ALL)       NOPASSWD: ALL/%wheel        ALL=(ALL)       NOPASSWD: ALL/gi' /etc/sudoers
sudo sed -i 's/# %wheel.*ALL=(ALL).*NOPASSWD: ALL/%wheel        ALL=(ALL)       NOPASSWD: ALL/gi' /etc/sudoers


Example to create user as "centos" in apache(48), add to sudoers, and enable sudoers to run commands with no password:

#!/bin/bash
sudo useradd -g 48 centos
sudo usermod -aG wheel centos
sudo sed -i 's/# %wheel        ALL=(ALL)       NOPASSWD: ALL/%wheel        ALL=(ALL)       NOPASSWD: ALL/gi' /etc/sudoers
sudo sed -i 's/# %wheel.*ALL=(ALL).*NOPASSWD: ALL/%wheel        ALL=(ALL)       NOPASSWD: ALL/gi' /etc/sudoers