Linux & VPS

Fix "user is not in the sudoers file" on Linux

is not in the sudoers fileThis incident will be reportedsudo: command not found
5 min read Updated 12 June 2026 ESAGAMES Team

This means your user doesn't have permission to use sudo. The fix is to add it to the right group — but you need an account that already has root/sudo to do it. Here's both.

Add the user to the sudo group

As root (or another sudo user), add your user to the admin group — sudo on Debian/Ubuntu, wheel on RHEL/Alma/Rocky:

# Debian/Ubuntu
usermod -aG sudo username
# RHEL/Alma/Rocky
usermod -aG wheel username
# then log out and back in

No root or sudo access at all?

If no account can elevate, use your provider's VNC/serial console or boot to single-user/rescue mode to log in as root, then run the command above.

Edit sudoers safely with visudo

Never edit /etc/sudoers directly — a syntax error locks everyone out of sudo. Always use visudo, which validates the file before saving.

"sudo: command not found"

That's different — sudo isn't installed. As root: apt install sudo or dnf install sudo.

Add the user to sudo (Debian) or wheel (RHEL) as root, re-login, and always edit sudoers with visudo.

A VDS with full root + console

Our VDS plans give you full root and VNC console access, so you're never locked out — protected NVMe in Frankfurt.

See VDS plans
FAQ

Frequently asked questions

How do I fix "user is not in the sudoers file"?

As root or another sudo user, add your account to the sudo group (Debian/Ubuntu) or wheel group (RHEL/Alma/Rocky) with usermod -aG, then log out and back in.

What if no user has sudo or root access?

Use your provider's VNC/serial console or boot into rescue/single-user mode to log in as root, then add your user to the sudo/wheel group.

How do I safely edit the sudoers file?

Always use the visudo command, never a normal editor. visudo checks the syntax before saving, so a typo can't lock everyone out of sudo.

Knowledge base

Related articles

Skip the troubleshooting

Managed, protected hosting in Frankfurt — we handle the Linux, the network and the DDoS so you don't have to.

Payments Secure checkout with cards, banking apps and digital wallets.

Choose the payment flow that fits your stack and region without leaving the platform.

Pay by Zen Visa Mastercard Paysafecard PaysafeCash Skrill Trustly Bancontact UnionPay iDeal WebMoney