mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-13 22:30:37 +08:00
commit
8a44188938
@ -1,102 +0,0 @@
|
||||
[#]: 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: "geekpi"
|
||||
[#]: 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 <yourusername>`
|
||||
|
||||
- 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
|
@ -0,0 +1,103 @@
|
||||
[#]: 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: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
如何修复:“sudo Command Not Found” 错误
|
||||
======
|
||||
|
||||
**以下是你如何在 Debian、Ubuntu 和其他发行版中修复 “sudo command not found” 错误的方法**。
|
||||
|
||||
有时,当你第一次设置或安装 [Linux 发行版][1]时,你在用 sudo 尝试一些命令时,会出现 “sudo command not found” 的错误。
|
||||
|
||||
sudo 命令是 “superuser do” 的缩写,它是一个允许用户以管理员权限执行命令的程序。sudo 命令帮助你像管理员用户一样运行程序/命令。
|
||||
|
||||
此外,用 sudo 运行命令的用户必须是 sudo 组的一部分。
|
||||
|
||||
你看到这个错误的主要原因是该软件包本身没有安装。然而,大多数现代 Linux 发行版都默认提供了这个功能,但有些则没有。
|
||||
|
||||
下面是解决这个问题需要遵循的步骤。
|
||||
|
||||
#### 故障排除#1
|
||||
|
||||
- 首先,安装 sudo 包来解决这个问题。打开一个终端,刷新你的系统,并运行以下命令来安装 sudo。
|
||||
|
||||
对于 Ubuntu、Debian 和相关发行版:
|
||||
|
||||
```
|
||||
su -apt updateapt install sudo
|
||||
```
|
||||
|
||||
对于 Arch Linux:
|
||||
|
||||
```
|
||||
pacman -S sudo
|
||||
```
|
||||
|
||||
对于 Fedora、RHEL 等:
|
||||
|
||||
```
|
||||
su -dnf updatednf install sudo
|
||||
```
|
||||
|
||||
- 上述安装完成后,你必须使用以下命令将用户添加到 `sudo` 组中。
|
||||
|
||||
`usermod -aG sudo <yourusername>`
|
||||
|
||||
- 然后从终端运行 `visudo`,并运行以下行。按 CTRL+O 和 CTRL+X 来保存和退出。
|
||||
|
||||
|
||||
![使用 visudo 更新 sudoers 文件][2]
|
||||
|
||||
- 退出并再次登录使变化生效。
|
||||
|
||||
#### 故障排除#2
|
||||
|
||||
在做了上述改变之后,如果你仍然收到错误信息,那么请按照以下步骤操作。
|
||||
|
||||
确保你的 `$PATH` 变量包含 `sudo` 可执行文件的正确路径。如果 `sudo` 已经安装,但 `$PATH` 不正确,你也会得到这个错误。理想情况下,你的路径应该包含以下所有的路径。
|
||||
|
||||
```
|
||||
echo $PATH
|
||||
```
|
||||
|
||||
```
|
||||
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
|
||||
```
|
||||
|
||||
要改变路径变量,使用以下命令。例如,如果 `/usr/bin` 不存在,那么你可以通过以下方式添加它。
|
||||
|
||||
```
|
||||
export PATH=$PATH:/usr/bin
|
||||
```
|
||||
|
||||
然后注销并登录查看效果。
|
||||
|
||||
### 总结
|
||||
|
||||
我希望这个指南能帮助你解决 Linux 发行版中的 sudo 错误。表面上的解决方案很简单,真的。
|
||||
|
||||
如果有帮助,或者如果你有任何问题,请在下面留言,。
|
||||
|
||||
[参考][3]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/sudo-command-not-found/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者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
|
Loading…
Reference in New Issue
Block a user