apt install sudo or dnf install sudo. “alex is not in the sudoers file” means the user has no sudo rights: as root, run usermod -aG sudo alex on Ubuntu/Debian or usermod -aG wheel alex on AlmaLinux/Rocky, then log out and back in. Both fixes need root, through su - or the VNC console.
This incident will be reported. instead.
Before you start
- All fixes need root. If you know the root password, switch with
su -. If not, reset the root password and log in as root on the VNC console. On a dedicated server, open a ticket for KVM/IPMI access. - Commands below run as root, so they have no
sudoin front.
Cause 1: sudo isn’t installed (command not found)
Minimal installs, for example Debian installed with a root password, don’t include sudo. Check:- Ubuntu / Debian
- AlmaLinux / Rocky
/usr/bin/sudo exists but the shell can’t find it, your PATH is broken. Check with echo $PATH: it should contain /usr/bin. Fix the line that changes PATH in ~/.bashrc or ~/.profile.
Cause 2: The user isn’t allowed to use sudo
Check the user’s groups:sudo group; AlmaLinux and Rocky use wheel.
Fix as root:
- Ubuntu / Debian
- AlmaLinux / Rocky
-a: without it, usermod -G removes the user from all other groups. Then log out and back in. Group changes only apply to new logins. For a full walkthrough, see create a sudo user.
Cause 3: sudo asks for a password you don’t know
sudo asks for your own password, not root’s. Users created only with an SSH key may have no password at all, so every attempt ends withSorry, try again. or sudo: a password is required.
Fix as root, set a password for the user:
Cause 4: A broken sudoers file
A typo in/etc/sudoers or a file in /etc/sudoers.d/ makes sudo print errors, ignore the broken rule, or refuse to run at all, depending on the error and sudo version:
visudo -c should end with parsed OK for every file. Always edit sudoers with visudo: it refuses to save a file with errors.
If a chmod -R or chown -R on / or /usr changed system files, sudo stops with sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set. As root:
Cause 5: “Permission denied” even with sudo
sudo echo "text" > /etc/example.conf, only echo runs as root. The > redirection is done by your own shell, as your user.
Fix: let a root process write the file:
tee -a appends instead of overwriting. See Linux file permissions explained.
How to check it worked
Log in again as the user and run:Frequently asked questions
Is the “incident” really reported to someone?
sudo logs the attempt (in the journal or/var/log/auth.log on Ubuntu/Debian, /var/log/secure on AlmaLinux/Rocky) and, if mail is set up, can email root. Nobody outside your server is notified.
I added the user to the group but it still fails. Why?
The current session still has the old groups. Log out completely and log in again, then check withid.
Should I just use root instead of sudo?
Using a sudo user is safer: it limits mistakes and lets you disable root login over SSH.Related guides
VPS and dedicated server guides
Every guide in this section.
Create a sudo user
Set up an admin user properly.
Manage users and groups
useradd, usermod and groups.
File permissions explained
chmod and chown without surprises.
Disable root login
The next step once sudo works.
Checked against the official sudo manual, sudoers manual and visudo manual on 4 November 2026; the “not in the sudoers file” message, adding the user to the
sudo group, the sudoers syntax error, visudo -c / -cf, the redirection error and the tee fix were tested with a temporary user on Ubuntu 24.04 LTS (sudo 1.9.15p5). The AlmaLinux wheel steps were not tested.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026