Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If Linux returns sudo: command not found, install sudo through a privileged route that does not depend on sudo itself. Use an existing root account, su –, another administrator, or recovery/live media. After installing the package, authorize your user through the distribution’s administrative group and start a new login session.

This guide covers Debian, Ubuntu, Fedora, RHEL, Rocky Linux, AlmaLinux, Arch Linux, and Alpine Linux, including safe sudoers configuration and common installation failures.

Before installing sudo

Check whether the command exists and whether your current PATH can find it:

ls -l /usr/bin/sudo
echo “$PATH”

If /usr/bin/sudo exists but the shell cannot find sudo, the problem may be the PATH. If the file is missing, install the package as root.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A normal user cannot use sudo to install sudo when it is missing. Obtain a root shell first:

su –

Enter the root password when prompted. If the root account is locked or has no usable password, use an existing administrator account, recovery mode, or live-media repair instead.

Install sudo on Linux

Run the command for your distribution from a root shell. Do not prefix these commands with sudo until sudo is installed and configured.

Distribution Commands to run as root
Debian, Ubuntu, and derivatives

apt update
apt install sudo

Fedora, RHEL, Rocky Linux, AlmaLinux

dnf install sudo

Arch Linux

pacman -S sudo

Alpine Linux

apk add sudo

After installation, confirm that the executable is present:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ls -l /usr/bin/sudo

Give your user sudo access

Installing the package does not necessarily authorize every user to use it. Distributions commonly use different administrative groups:

Distribution family Administrative group
Debian and Ubuntu sudo
RHEL family wheel
Arch Linux wheel

Replace USERNAME below with the actual login name. Identify the current user with whoami.

Debian and Ubuntu

From the root shell, add the user to the sudo group:

usermod -aG sudo USERNAME

On Debian, this equivalent command is also available:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

adduser USERNAME sudo

RHEL, Rocky Linux, and AlmaLinux

Add the user to the wheel group:

usermod –append -G wheel USERNAME

RHEL’s sudoers configuration must also contain an active wheel rule:

%wheel ALL=(ALL) ALL

The line must not begin with an ordinary comment marker. If it begins with # in the sudoers file, enable it safely with visudo, as described below.

Arch Linux

Add the user to wheel:

usermod -aG wheel USERNAME

Then use visudo to enable the corresponding %wheel rule in /etc/sudoers.

Start a new session

Group changes do not normally affect an existing login session. Log out completely and log in again. For a temporary shell-only change, you can use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

newgrp sudo

On systems using wheel, use:

newgrp wheel

A new login session is the more reliable solution. Verify membership after logging in again:

id USERNAME

The output should include sudo on Debian/Ubuntu or wheel on RHEL and Arch.

Test sudo

Check the permissions granted to the current user:

sudo -l

For a more detailed listing of the effective configuration, run:

sudo -ll

Finally, test a harmless command that reports the effective identity:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

sudo id

A successful result normally includes:

uid=0(root)

The standard form is:

sudo COMMAND

For example:

sudo apt update

Sudo runs the specified command with elevated privileges; it does not automatically open a root shell. If you specifically need a root login shell, use:

sudo -i

Sudo -i changes the environment to a root login environment, so use it only when an interactive root shell is appropriate.

Configure sudo safely with visudo

The main configuration file is:

/etc/sudoers

Never edit this file directly with Nano, Vim, or another normal editor. Use:

visudo

Visudo locks the file while editing and checks its syntax before installing changes. A syntax error in sudoers can prevent sudo commands from working.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To grant one user full sudo access, the rule is:

USERNAME ALL=(ALL) ALL

For a group, use the appropriate rule:

%wheel ALL=(ALL) ALL

On Debian and Ubuntu, the equivalent group rule is:

%sudo ALL=(ALL:ALL) ALL

When visudo reports an error, choose e to re-edit or x to exit without saving. Do not choose Q to save invalid syntax.

Use a sudoers drop-in file

Distribution packages commonly load additional rules from:

/etc/sudoers.d/

Create or edit a drop-in with:

visudo -f /etc/sudoers.d/10-USERNAME

Using a drop-in keeps local rules separate from the main configuration. The include directive may appear in /etc/sudoers as:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

#includedir /etc/sudoers.d

In this directive, the leading # is part of sudoers syntax; it does not mean the line is an ordinary comment.

Follow these naming rules:

  • Use consistent leading zeroes, such as 01-base, 10-backup, and 99-local.
  • Do not use filenames containing a period, such as backup.conf.
  • Do not end a file with ~; editor backup files are skipped.
  • Remember that files are read in lexical order. 10-second sorts before 2-first.

When multiple rules match, a later entry can override an earlier one. A syntactically valid drop-in can therefore still produce an unexpected permission result if another file is read later.

Troubleshoot common errors

sudo: command not found

The sudo package may be missing, or /usr/bin may not be in PATH. Check:

ls -l /usr/bin/sudo
echo “$PATH”

If the executable is absent, return to a root shell with su – and install the package using the command for your distribution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

username is not in the sudoers file

The package is installed, but the user is not authorized by the relevant group, /etc/sudoers, or a file in /etc/sudoers.d/. Check group membership:

groups USERNAME

Correct the group membership as root, then log out and back in. Also check that the matching group rule is enabled in sudoers.

The group was added, but sudo still fails

The current session may still have its old supplementary groups. Start a new login session. newgrp sudo or newgrp wheel can provide a temporary shell-based workaround.

su – returns an authentication error

The root account may be locked or may not have a password. This is common on Ubuntu desktop installations, which commonly do not provide a usable root password. If sudo is also missing, use recovery mode, live media, or another existing privileged administration path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

visudo: /etc/sudoers: Permission denied

You did not run visudo as root. Obtain a root shell first, then run it again.

/etc/sudoers is missing or has bad permissions

The file must exist as a regular file or symbolic link and have suitable ownership and permissions. On systems using the documented Arch defaults, repair it from a root shell with:

chown -c root:root /etc/sudoers
chmod -c 0440 /etc/sudoers

Packaging defaults can differ between distributions, particularly for group ownership, so verify the expected values on the affected system before changing them.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A drop-in rule is ignored

Check the filename first. Files containing a period or ending in ~ are skipped. Then inspect all drop-ins for lexical ordering and conflicting rules. A later matching entry can override an earlier one.

Sudo fails over SSH

SSH does not allocate a terminal for remote commands by default. If the system requires a TTY, allocate one explicitly:

ssh -t HOSTNAME sudo COMMAND

Be careful when sending commands remotely: password prompts and shell input can behave differently without an interactive terminal.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Installation checklist

  1. Obtain root access without sudo.
  2. Install the sudo package using the distribution’s package manager.
  3. Add the user to sudo or wheel.
  4. Enable the relevant group rule if the distribution requires it.
  5. Log out and back in.
  6. Confirm membership with id USERNAME.
  7. Test with sudo -l and sudo id.

FAQ

Can I install sudo with sudo apt install sudo if sudo is missing?

No. If sudo is not installed, that command cannot run. Become root with su –, use another administrative route, or repair the system through recovery mode or live media.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does sudo ask for the root password?

Normally, sudo authenticates the invoking user and asks for that user’s sudo password. A system can be configured differently, but prompting for the root password is not the default behavior.

Why does sudo still fail after I add my user to the group?

The existing login session has not acquired the new supplementary group. Log out completely and log back in, then verify the result with id USERNAME.

Which group should I use for sudo access?

Debian and Ubuntu commonly use sudo. RHEL-family systems and Arch commonly use wheel. The group must also have a matching enabled rule in the sudoers configuration.

Does sudo open a root shell?

No. sudo COMMAND elevates only that command. Use sudo -i when you specifically need a root login shell.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Bottom Line

Install sudo from a root shell, not through sudo itself. Then add the account to the correct administrative group—sudo on Debian/Ubuntu or wheel on RHEL and Arch—start a new login session, and verify with sudo -l and sudo id. If you change sudoers, always use visudo so a syntax mistake does not lock you out of administrative access.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.