centos安装了curl却报 -bash: curl: command not found

前因

我服务器上想用curl下载docker-compress,发现没有curl命令,就去下载安装,安装完成之后,报-bash: curl: command not found

解决方法

[root@centos ~]# rpm -e --nodeps curl
warning: file /usr/bin/curl: remove failed: No such file or directory
 
[root@centos ~]# yum remove curl
Loaded plugins: fastestmirror, langpacks
No Match for argument: curl
No Packages marked for removal
 
[root@centos ~]# rpm -qa|grep curl
python-pycurl-7.19.0-19.el7.x86_64
libcurl-7.29.0-57.el7_8.1.x86_64
 
[root@centos ~]# yum -y install curl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package curl.x86_64 0:7.29.0-57.el7_8.1 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
============================================================================================================================================
 Package                     Arch                          Version                                     Repository                      Size
============================================================================================================================================
Installing:
 curl                        x86_64                        7.29.0-57.el7_8.1                           updates                        271 k
 
Transaction Summary
============================================================================================================================================
Install  1 Package
 
Total download size: 271 k
Installed size: 528 k
Downloading packages:
curl-7.29.0-57.el7_8.1.x86_64.rpm                                                                                    | 271 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 5 pre-existing rpmdb problem(s), 'yum check' output follows:
abrt-addon-kerneloops-2.1.11-57.el7.centos.x86_64 has missing requires of curl
abrt-addon-xorg-2.1.11-57.el7.centos.x86_64 has missing requires of curl
2:postfix-2.10.1-9.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-9.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
rpm-4.11.3-43.el7.x86_64 has missing requires of curl
  Installing : curl-7.29.0-57.el7_8.1.x86_64                                                                                            1/1 
  Verifying  : curl-7.29.0-57.el7_8.1.x86_64                                                                                            1/1 
Installed:
  curl.x86_64 0:7.29.0-57.el7_8.1                                                                                                           
Complete!
 
 
[root@centos ~]# curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.44 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp 
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets 
[root@centos ~]#

在这里插入图片描述

其实我第一次按照csdn一篇博客试了一下,是失败的,第二次又找了篇博客园的文章试了下,就成功了,但两篇文章的内容是一模一样的,也很离谱。

当你遇到“CentOS bash: curl: command not found”的错误信息时,这通常意味着你的系统上并未安装curl命令。`curl`是一个非常有用的工具,用于在Linux、Unix等系统上进行文件传输,支持HTTP、HTTPS等多种协议。 ### 解决方案: #### 通过软件包管理器安装 `curl` 如果你是在基于Debian的发行版如Ubuntu或基于Red Hat的发行版如CentOS/RHEL上运行,可以使用以下命令来安装curl: **对于Ubuntu / Debian**: ```bash sudo apt update sudo apt install curl ``` **对于CentOS / RHEL / Fedora**: ```bash sudo yum install curl ``` 或者,如果你正在使用的是Docker容器或类似环境,并且想要在容器内部安装curl,可以尝试: ```bash RUN apk add curl ``` 在Dockerfile中添加上述命令行即可安装curl。 #### 使用其他方法 如果上述方式不可行,或者你想避免使用特定的软件包管理器,你可以从curl的官方网站下载源码并手动编译安装: 1. **下载源码**: ```bash wget https://curl.se/download/curl-7.x.x.tar.gz # 替换x.x为你想使用的版本号 ``` 2. **解压下载的文件**: ```bash tar -xzvf curl-7.x.x.tar.gz ``` 3. **进入解压缩后的目录**: ```bash cd curl-7.x.x/ ``` 4. **配置、编译与安装**: ```bash ./configure make sudo make install ``` 完成以上步骤后,你应该能在终端中成功使用curl命令了。 ### 相关问题: 1. 如果curl命令仍然找不到怎么办? 2. 是否有更简单的方式在CentOS安装curl? 3. 在非Linux环境中如何安装curl? --- 注意:在实际操作过程中,请确保下载的是最新的稳定版本,同时根据具体的系统环境调整相应的命令行参数和路径。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值