The purpose of this tutorial is to show how to fix the RHEL7
User Not In Sudoers File Error on all major Linux distributions. When trying to execute Linux commands with root privileges via the
sudo command, you will receive an error message if the current user is not in the sudoers file. This is a security feature on Linux systems to stop ordinary users from esclating their commands to administrator privileges.
The remedy for this error is to add the user to the
sudo group on DEB based systems or to the
wheel group on RPM based systems. In this tutorial, you will see how to fix this error message and add a user to the respective group.
In this tutorial you will learn:
- How to enable sudo usage on DEB and RPM based Linux distributions
- How to resolve the RHEL7 User Not In Sudoers File Error
|Category||Requirements, Conventions or Software Version Used|
|System||Any DEB or RPM based Linux system|
|Other||Privileged access to your Linux system as root or via the
|Conventions||# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to fix: RHEL7 User Not In Sudoers File Error step by step instructions
You can always access the root account by simply logging in with the
sucommand. It is not strictly necessary to use
sudoor enable this functionality if you do not want to.
The error message looks like this:
$ sudo -i [sudo] password for linuxconfig: linuxconfig is not in the sudoers file. This incident will be reported.
Many users may see the RHEL7 User Not In Sudoers File Error on Red Hat Enterprise Linux or another major Linux distro.
In order to fix the error, all we need to do is add our user to the correct group. The correct group will depend on what distro you’re using. For RPM based distros, such as Red Hat, CentOS, Fedora, AlmaLinux, Rocky Linux, etc, this will be the
wheel group. For DEB based distros, such as Debian, Ubuntu, Linux Mint, etc, this will be the
Follow the step by step instructions below to add your user to the correct group and fix the RHEL7 User Not In Sudoers File Error.
- Start by opening a command line terminal and logging into the root user account.
$ su -i
- Then, add your user to the
sudogroup, depending on which distro you are running. In this example, we will add our user
linuxconfigto the groups, but substitute your own user name into the lines below.RPM based distros:
# usermod -aG wheel linuxconfig
DEB based distros:
# usermod -aG sudo linuxconfig
- To make the changes take effect, you will need to completely log out and log back in. Alternatively, you can just restart the system completely.
- When you log back into your system, you will be able to execute commands with root privileges by simply prefacing them with
sudo. Run some command to make sure it works.
$ sudo -i
In this tutorial, we saw how to fix the
user is not in the sudoers file error on RHEL7 and other RPM and DEB based Linux systems. Enabling
sudo usage for a user is the recommneded method to running commands with escalated privileges, rather than logging into the root account. This is done both for security and convenience. After all, who wants to login to the root account every time they need to do some administration task?