Hostxpeed
Login Get Started →
Security

How to Create sudoers File

5 min read
25 views
Jun 12, 2026

Step 1: Create New File in /etc/sudoers.d/

sudo visudo -f /etc/sudoers.d/custom-rules

Step 2: Add Rules

# Allow user to run apt commands without password
username ALL=(ALL) NOPASSWD: /usr/bin/apt update, /usr/bin/apt upgrade

# Allow group to run as www-data
%webteam ALL=(www-data) ALL

Step 3: Set Proper Permissions

sudo chmod 440 /etc/sudoers.d/custom-rules

Step 4: Validate Syntax

sudo visudo -c

Step 5: Test

sudo -k
sudo apt update

Was this article helpful?