提示-bash: command not found的解决方法集锦

14 篇文章 3 订阅
9 篇文章 0 订阅

错误原因

  最近很多小伙伴私信我说老是遇到命令找不到的情况,这里开一篇插个队说一下这个问题,做个总结。当我们在 Linux(或shell)下执行一个命令时,报 -bash: XXXX: command not found,有三个可能的原因:

  1. 你将命令的名称拼错了。

  2. 该命令还没有安装。

  3. 该命令是一个可执行脚本,但其位置未知。

解决方案

第一个很简单,仔细排查一下,命令或者文件名之类的写错了没有。

第三个这和Windows是相同的道理,都是环境变量惹的祸,就是说你的 命令的 执行文件不在 /usr/bin 或者 /etc/init.d 中,他就找不到 执行该命令的 文件来执行。思路是将该应用的 bin 目录 放入到 profile 文件中就OK了,步骤如下:

  1. find / -name profile #找到该文件(这个文件相当于 你在Windows 中加入环境变量那块),一般该文件在 /etc/profile 这里
  2. vim profile #编辑该文件
  3. export PATH="$PATH:/phpstudy/mysql/bin" #在该文件中加入 command not found 的应用 bin 目录,这里我是将 mysql 的 bin 放到这里,因为我是 mysqld / mysqldump / mysqladmin 命令用不了
  4. source /etc/profile // 更新配置(不用重启系统)

这还不行那就是第二个原因了,那就是没有安装这个插件了,解决办法如下:

  1. -bash: rz: 未找到命令
    yum install lrzsz

  2. 提示-bash: telnet: command not found的解决方法

yum list telnet*                  列出telnet相关的安装包
yum install telnet-server         安装telnet服务
yum install telnet.*              安装telnet客户端
  1. -bash: wget: command not found
    yum install wget -y

Debian/Ubuntu系统,需要执行以下命令:
apt-get install -y wget

  1. -bash: unzip: command not found
    yum install unzip

  2. -bash: ntpdate: command not found
    yum install ntpdate

  3. -bash: nmap: command not found
    yum install nmap

  4. -bash: lsof: command not found
    yum install lsof -y

  5. -bash: fuser: command not found
    yum install psmisc

  6. -bash: yum-config-manager: command not found
    yum -y install yum-utils

  7. -bash: psql: command not found
    yum install postgresql 或者 yum install postgresql-server

  8. ifconfig: command not found
    yum install -y net-tools

  9. -bash: netstat: command not found
    yum install -y net-tools

  10. firewall-cmd: command not found
    yum install firewalld -y

  11. multipath: command not found
    yum install device-mapper-multipath

  12. ip: command not found (CentOS Linux release 7.8.2003 (Core) )
    yum install initscripts

  13. autoreconf: command not found
    yum install install autoconf -y

  14. autoreconf: failed to run autopoint: No such file or directory err:
    autoreconf: running: autopoint --force
    Can’t exec “autopoint”: No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 345.
    autoreconf: failed to run autopoint: No such file or directory
    autoreconf: autopoint is needed because this package uses Gettext fixed:
    yum install -y gettext-devel

  15. yum-builddep: command not found
    yum install yum-utils -y

  16. rpmbuild: command not found
    yum install rpm-build -y

  17. Redirecting to /bin/systemctl stop iptables.service
    Failed to stop iptables.service: Unit iptables.service not loaded.
    yum install iptables-services
    实际上,centos7后是使用的基于iptable的

systemctl stop firewalld
systemctl mask firewalld

设置开机启动:

systemctl stop iptables
systemctl start iptables
systemctl restart iptables
systemctl reload iptables
systemctl enable iptables

保存设置:
service iptables save

1)查看防火状态

    systemctl status firewalld
    service  iptables status

2)暂时关闭防火墙

    systemctl stop firewalld
    service  iptables stop

3)永久关闭防火墙

 systemctl disable firewalld
 chkconfig iptables off

4)重启防火墙

 systemctl enable firewalld
 service iptables restart  

5)永久关闭后重启(未测试)
chkconfig iptables on

转载自:https://blog.csdn.net/u014727709/article/details/130915064
欢迎start,欢迎评论,欢迎指正

  • 10
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想你依然心痛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值