未找到命令curl,即使已安装

未找到命令curl,即使已安装

首先我安装了curl

company@rb-VirtualBox:~$ apt install curl
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

company@rb-VirtualBox:~$ sudo apt install curl
[sudo] password for company: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
curl is already the newest version (7.68.0-1ubuntu2.7).
0 upgraded, 0 newly installed, 0 to remove and 552 not upgraded.

然后我尝试使用它:

company@rb-VirtualBox:~$ ​curl -X GET 'http://localhost:9200'

Command '​curl' not found, did you mean:

  command 'curl' from deb curl (7.68.0-1ubuntu2.7)

Try: apt install <deb name>

正如您所看到的,它仍然显示“未找到命令'​curl'”。

如果我使用完整路径执行它,如下所示:

company@rb-VirtualBox:~$ /usr/bin/curl -X GET 'http://localhost:9200'

然后就可以了


更多信息:

company@rb-VirtualBox:~$ whereis curl
curl: /usr/bin/curl /usr/share/man/man1/curl.1.gz

company@rb-VirtualBox:~$ echo $PATH
/home/company/.nvm/versions/node/v17.8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

答案1

我不知道为什么,但在调用它之后

company@rb-VirtualBox:~$ /usr/bin/curl -X GET 'http://localhost:9200'

现在突然这也起作用了:

company@rb-VirtualBox:~$ curl -X GET 'http://localhost:9200'

更新:

正如 @jesse_b 在评论中正确假设的那样,这是因为我从网站复制了命令以及一些可疑字符,例如\r\n,这些字符导致了错误。

相关内容