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.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
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 |
| 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.
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:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →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:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →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:
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.
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:
#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:
Rank #4
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.
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.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsvisudo: /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.
Best Value
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.Installation checklist
- Obtain root access without sudo.
- Install the sudo package using the distribution’s package manager.
- Add the user to sudo or wheel.
- Enable the relevant group rule if the distribution requires it.
- Log out and back in.
- Confirm membership with id USERNAME.
- 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.
Recommended Free Tools
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.
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.
Quick Recap
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.

