Check out example codes for "add user to sudoers". It will help you in understanding the concepts better.

Code Example 1

usermod -aG sudo username

Code Example 2

echo "username  ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/username

Learn ReactJs, React Native from akashmittal.com