Fix: sudo command not found

The “sudo: command not found” error means the system can’t find the ‘sudo’ command, which is needed for running commands as a superuser. This often happens if the ‘sudo’ package isn’t installed on the system. In Debian-based systems, ‘sudo’ might not be installed by default if you set a root password during installation.

Also, this error can occur if the ‘sudo’ command is missing from the system’s PATH, making it hard for the system to locate it.

Now that you know the causes, let’s discuss the solutions.

1. Fix Sudo Ccommand Not Found Errors on GNU/Linux

It’s unusual for a Linux distribution to lack sudo, but if you type sudo fdisk -l and receive a “sudo: command not found” error, sudo might not be installed. To check, type whereis sudo. If it only returns “sudo:”, it’s not installed.

Log in as the root user by pressing Ctrl, Alt, and F1 or F2 to access a terminal. Type ‘root’ and enter the password. You’ll see a # symbol.

For apt-based systems, type apt-get install sudo and press Enter. For yum-based systems, use yum install sudo. Follow the prompts to install.

Type visudo to open an editor. Add a line with your username like this:

user ALL=(ALL) ALL

If using vi, press Esc, then :wq to save and exit. For GNU nano, press Ctrl + O to save, then Ctrl + X to exit. Now you can use sudo normally.

2. Fix Sudo Command Not Found Errors on FreeBSD and Other Unices

While BSD operating systems generally include the su command, they usually don’t come with the sudo command. First, log out of your user account and go to the Unix login screen. Enter ‘root’ as the username, press Enter, then type the root password and press Enter again.

You will see a # symbol, showing you’re logged in as a privileged user. To install sudo, type pkg_add -rv sudo and press Enter. Agree to the installation if prompted, and wait for it to complete. Once it’s installed, type visudo and press Enter. To allow a user named billy to run any command, add this line at the end of the file:

billy ALL=(ALL) ALL

Replace “billy” with your actual username. If visudo opens in vi, press Esc, then type :wq to save and exit the editor. You can then log out and use sudo normally.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.