From 88440a395f400b18c38263cf6dab7bf87963f673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AD=E5=BC=80=E7=AE=B1?= Date: Sat, 12 Nov 2022 19:47:23 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][tech]:?= =?UTF-8?q?=2020221110.0=20=E2=AD=90=EF=B8=8F=20How=20to=20Fix=20sudo=20Co?= =?UTF-8?q?mmand=20Not=20Found=20Error.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...️ How to Fix sudo Command Not Found Error.md | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 sources/tech/20221110.0 ⭐️ How to Fix sudo Command Not Found Error.md diff --git a/sources/tech/20221110.0 ⭐️ How to Fix sudo Command Not Found Error.md b/sources/tech/20221110.0 ⭐️ How to Fix sudo Command Not Found Error.md new file mode 100644 index 0000000000..4641133f19 --- /dev/null +++ b/sources/tech/20221110.0 ⭐️ How to Fix sudo Command Not Found Error.md @@ -0,0 +1,102 @@ +[#]: subject: "How to Fix: sudo Command Not Found Error" +[#]: via: "https://www.debugpoint.com/sudo-command-not-found/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +How to Fix: sudo Command Not Found Error +====== + +**Here’s how you can fix the “sudo command not found” error in Debian, Ubuntu and other distros.** + +Sometimes, when you set up or install [Linux distributions][1] for the first time, you get the “sudo command not found” error while trying some commands with sudo. + +The sudo command is an abbreviation of “superuser do”, and it is a program which allows a user to execute a command with admin privileges. The sudo command helps you run programs/commands like an admin user. + +Also, the user, who is running the command with sudo must be a part of the sudo group. + +The primary reason you get this error is that the package itself is not installed. However, most modern Linux distribution provides this by default, but some don’t. + +Here are the steps you should follow to fix it. + +#### Troubleshooting#1 + +- First, install the sudo package to fix the problem. Open a terminal, refresh your system and run the following commands to install sudo. + +For Ubuntu, Debian and related distros: + +``` +su -apt updateapt install sudo +``` + +For Arch Linux: + +``` +pacman -S sudo +``` + +For Fedora, RHEL, etc: + +``` +su -dnf updatednf install sudo +``` + +- After the above installation is complete, you have to add the user to `sudo` group using the following command + +`usermod -aG sudo ` + +- Then run the `visudo` from the terminal and the following line. Press CTRL+O and CTRL+X to save & exit. + +![Updating the sudoers file using visudo][2] + +- Log off and log in again to reflect the change. + +#### Troubleshooting#2 + +After the above change, if you are still getting the error, then follow the below steps. + +Make sure your `$PATH` variable contains the proper path to the `sudo` executable. If the `sudo` is installed, but the `$PATH` is incorrect, you can also get this error. Ideally, your path should contain all the below paths. + +``` +echo $PATH +``` + +``` +/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin +``` + +To change the path variable, use the following command. For example, if the `/usr/bin` is not present, then you can add it via below + +``` +export PATH=$PATH:/usr/bin +``` + +Then log out and log in to see the effect. + +### Wrapping Up + +I hope this guide helps you to fix the sudo error in your Linux distros. The apparent solution is quite simple, really. + +Drop a note below if it helps/or if you have any questions. + +[Reference][3] + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/sudo-command-not-found/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/category/distributions +[2]: https://www.debugpoint.com/wp-content/uploads/2022/09/Updating-the-sudoers-file-using-visudo.jpg +[3]: https://linux.die.net/man/8/sudo