sudo
command is used to execute command as another user. This is generally used to run command as root
. In some cases we can get an error like -bash:sudo:command not found
which means sudo
is not installed. In this tutorial we will look different ways and distributions to solve this problem.
sudo
命令用于以另一个用户身份执行命令。 通常用于以root
身份运行命令。 在某些情况下,我们会收到-bash:sudo:command not found
类的错误,这意味着未安装sudo
。 在本教程中,我们将探讨解决此问题的不同方式和分布。
为Debian,Ubuntu,Mint,Kali安装Sudo (Install Sudo For Debian, Ubuntu, Mint, Kali)
We can install sudo
for Debian, Ubuntu, Mint and Kali related distributions for deb
or apt
with the following command. But before we should be root
user because package installation requires root
privileges.
我们可以安装sudo
适用于Debian,Ubuntu的,薄荷和卡利相关发行deb
或apt
使用下面的命令。 但是在我们应该是root
用户之前,因为软件包安装需要root
特权。
$ su
$ apt install sudo
为CentOS,Fedora,RHEL安装Sudo (Install Sudo For CentOS, Fedora, RHEL)
We can install sudo
for CentOS, Fedora and RHEL related distributions for rpm or yum with the following command. But before we should be root
user because package installation requires root
privileges.
我们可以使用以下命令为rpm或yum安装与CentOS,Fedora和RHEL相关的发行版的sudo
。 但是在我们应该成为root
用户之前,因为软件包安装需要root
特权。
$ su
$ yum install sudo
添加用户Sudoers配置文件 (Add User Sudoers Configuration File)
sudo
command provides fast way to change root
user. But this is done with a configuration file locate /etc/sudoers
. sudoers
file contains users and their ability to run sudo
command. Most of the distributions automatically adds user to this file but in some cases this may fail. We can add following line to make user able to run sudo
. In this example we will use user name ismail
sudo
命令提供了更改root
用户的快速方法。 但这是通过配置文件locate /etc/sudoers
。 sudoers
文件包含用户及其运行sudo
命令的能力。 大多数发行版会自动将用户添加到该文件,但是在某些情况下,这可能会失败。 我们可以添加以下行以使用户能够运行sudo
。 在此示例中,我们将使用用户名ismail
ismail ALL=(ALL) ALL
成为另一个用户 (Become Another User)
While using sudo if we need to change user other than root we should provide the user name after the sudo
command . In this example we will change to the user ali
在使用sudo时,如果需要更改root用户以外的其他用户,则应在sudo
命令后提供用户名。 在此示例中,我们将更改为用户ali
$ sudo ali
翻译自: https://www.poftut.com/bash-sudo-command-not-found-error-solution-linux-debian-centos/