-bash:sudo:找不到命令错误和解决方法
时间:2020-01-09 10:38:04 来源:igfitidea点击:
执行sudo报错
但是,出现错误:
-bash: sudo: command not found
如何在Debian/Ubuntu/RHEL/CentOS Linux下解决此问题?
此错误意味着未安装sudo命令。
sudo命令允许允许用户以超级用户或另一个用户的身份执行命令,如sudoers文件中所指定。
步骤1:成为root用户
使用su命令,如下所示:
$ su
出现提示时,您需要输入root用户密码。
步骤2:在Linux下安装sudo工具
如果您使用的是Debian或Ubuntu Linux,请输入:
# apt-get install sudo
输出示例:
Reading package lists... Done Selecting previously deselected package sudo. (Reading database ... 30838 files and directories currently installed.) Unpacking sudo (from .../sudo_1.7.4p4-2.squeeze.3_amd64.deb) ... Processing triggers for man-db ... Setting up sudo (1.7.4p4-2.squeeze.3) ... No /etc/sudoers found... creating one for you.
如果您使用的是RHEL/CentOS/Fedora/Scientific Linux,请输入:
# yum install sudo
输出示例:
Installed size: 0 Is this ok [y/N]: y Downloading Packages: sudo-1.7.4p5-12.el6_3.x86_64.rpm | 423 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : sudo-1.7.4p5-12.el6_3.x86_64 1/1 Installed products updated. Verifying : sudo-1.7.4p5-12.el6_3.x86_64 1/1 Installed: sudo.x86_64 0:1.7.4p5-12.el6_3 Complete!
步骤3:将管理员用户添加到/etc/sudoers
您需要将自己添加到/etc/sudoers文件中,输入:
# visudo
通过sudo授予Hyman用户完全权限:
Hyman ALL=(ALL) ALL
保存并关闭文件。
如何使用sudo?
要成为root用户并启动root shell,请输入:
$ sudo -i
或者
$ sudo -s
要运行名为/sbin/service httpd restart的命令,请输入:
$ sudo /sbin/service httpd restart
要重新加载鱿鱼代理服务器,请输入:
$ sudo /usr/sbin/squid3 -k reconfigure
输出示例:
We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for Hyman: