如何在Debian Linux 10/9/8上安装curl

时间:2020-01-09 10:40:19  来源:igfitidea点击:

在Debian Linux 10 从shell脚本运行curl命令,但收到以下错误:

bash: curl: command not found
bash:curl:命令未找到

如何在Debian Linux版本10或9/8上解决此问题?

" curl"命令是在Linux或类Unix系统上使用FTP,HTTP,HTTPS,SCP,SFTP,SMB和其他受支持的协议从服务器下载文件或数据或向服务器传输文件/数据的工具。

使用apt命令或apt-get命令使用curl可以在Debian Linux上轻松安装和使用curl命令。
本教程显示如何在Debian Linux 10/9/8版上安装curl。

在Debian上安装Curl

  • 打开终端applicationUpdate系统,运行:sudo apt update && sudo apt upgrade
  • 在Debian上安装curl,执行:sudo apt install curl
  • 测试卷曲

让我们看看如何在Debian上安装和使用curl。

如何在Debian Linux 10/9/8上安装curl

执行以下命令以在Debian Linux上安装curl:

$ sudo apt install curl

或者

$ sudo apt-get install curl

输出示例:

[sudo] password for Hyman: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libcurl3
The following NEW packages will be installed:
  curl libcurl3
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 518 kB of archives.
After this operation, 989 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.kernel.org/debian stretch/main amd64 libcurl3 amd64 7.52.1-5 [291 kB]
Get:2 http://mirrors.kernel.org/debian stretch/main amd64 curl amd64 7.52.1-5 [227 kB]
Fetched 518 kB in 4s (116 kB/s)
Selecting previously unselected package libcurl3:amd64.
(Reading database ... 240584 files and directories currently installed.)
Preparing to unpack .../libcurl3_7.52.1-5_amd64.deb ...
Unpacking libcurl3:amd64 (7.52.1-5) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.52.1-5_amd64.deb ...
Unpacking curl (7.52.1-5) ...
Setting up libcurl3:amd64 (7.52.1-5) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up curl (7.52.1-5) ...

用法

安装后,您可以按以下方式使用它来查看标题:

$ curl -I https://www.google.co.in/
$ curl -I https://www.theitroad.local/

输出示例:

HTTP/2 200 
server: nginx
date: Tue, 03 Oct 2016 05:24:03 GMT
content-type: text/html;charset=utf-8
vary: Accept-Encoding
cache-control: public,max-age=14400,s-maxage=14400,must-revalidate
expires: Tue, 03 Oct 2016 09:14:57 GMT
etag: d01116f2eda45a43e65b0242ed052e73
last-modified: Sat, 23 Sep 2016 17:37:16 GMT
strict-transport-security: max-age=15768000
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1
x-whome: l-cbz01

或使用curl本身从服务器下载文件:

curl -o output.file http://server1.theitroad.local/foo.bar.txt

您可以使用curl命令恢复中断的下载,如下所示:

curl -L -O -C - http://ftp.ussg.iu.edu/linux/centos/latest/isos/file.iso